wwwjfy on pyup-update-pytest-4.1.0-to-4.2.0
wwwjfy on master
Update pytest from 4.1.0 to 4.2… (compare)
fantix on pyup-update-pytest-4.1.0-to-4.2.0
Update pytest from 4.1.0 to 4.2… (compare)
fantix on pyup-update-pytest-4.1.0-to-4.2.0
wwwjfy on pyup-update-quart-0.6.10-to-0.7.0
wwwjfy on pyup-update-flake8-3.5.0-to-3.7.1
wwwjfy on master
Update flake8 from 3.5.0 to 3.7… use latest flake8 in tests, ref… Merge pull request #430 from fa… (compare)
wwwjfy on pyup-update-flake8-3.5.0-to-3.7.1
use latest flake8 in tests, ref… (compare)
UninitializedError
?
main.py
?
from sanic import Sanic
from gino.ext.sanic import Gino
app = Sanic("app name")
app.config.DB_HOST = "127.0.0.1"
app.config.DB_USER = "fantixking"
db = Gino()
db.init_app(app)
class InfoModel(db.Model):
__tablename__ = "infomodel"
@app.route("/test")
async def test(request):
info = await InfoModel.query.gino.first()
ret = 'INFO MODEL domain: %s' % info.domain
return HTTPResponse(ret, content_type='text/html')
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
python -m MyServer.main
Traceback (most recent call last):
File "####/env/lib/python3.6/site-packages/sanic/app.py", line 976, in handle_request
response = await response
File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "####/project/handlers.py", line 12, in test
info = await InfoModel.query.gino.first()
File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "####/env/lib/python3.6/site-packages/gino/api.py", line 137, in first
return await self._query.bind.first(self._query, *multiparams, **params)
File "####/env/lib/python3.6/site-packages/gino/api.py", line 544, in __getattribute__
raise self._exception
gino.exceptions.UninitializedError: Gino engine is not initialized.
This issue has something to do with the files being split up. I used your example and incrementally added my configs, and whatnot. It started going wrong as soon as I put the handler in it's own file.
I have 2 identical (save for the path) handlers: one on the test.py file and one in a module's handlers.py file. The one on test.py works fine.
'pool_pre_ping' sent to create_engine(), using configuration AsyncpgDialect/GinoEngine. Please checkthat the keyword arguments are appropriate for this combination of components.
loader = Parent.load(add_child=Childern.on(child_and_clause))
result = (
await loader.query.where(Parent.id == parent_id)
.where(Parent.knowledge_end_date == None)
.gino.first()
)
child_and_clause
is working fine as the output is correct, justa that it is being added multiple times
from gino.ext.sanic import Gino
db = Gino()
I'm using Gino inside my Celery apps using this line
async with db.with_bind(settings.SQL_DRIVER, echo=False) as engine:
For some reason I can't get echo to turn off.
Hi! @rlundy82. I came across the same issue while using uvicorn with Sanic+Gino. the easiest way to disable db echo is to set a higher logging level to gino_logger:
import logging
logging.getLogger("gino").setLevel(logging.WARNING)
create_user()
instead of User.create()
User.create
method
create()
and create_all()
functions are a bit less elegant - they're copied from SQLAlchemy and manipulated to be async, so I'm overall not a big fan
create_async
or GinoSchemaVisitor.create
might be the places to override