gino.ext.sanic module

class gino.ext.sanic.Gino(app=None, *args, **kwargs)[source]

Bases: gino.api.Gino

Support Sanic web server.

By init_app() GINO registers a few hooks on Sanic, so that GINO could use database configuration in Sanic config to initialize the bound engine.

A lazy connection context is enabled by default for every request. You can change this default behavior by setting DB_USE_CONNECTION_FOR_REQUEST config value to False. By default, a database connection is borrowed on the first query, shared in the same execution context, and returned to the pool on response. If you need to release the connection early in the middle to do some long-running tasks, you can simply do this:

await request['connection'].release(permanent=False)
coroutine first_or_404(*args, **kwargs)[source]
init_app(app)[source]
model_base_classes = (<class 'gino.crud.CRUDModel'>, <class 'gino.ext.sanic.SanicModelMixin'>)
query_executor

alias of GinoExecutor

coroutine set_bind(bind, loop=None, **kwargs)[source]

Bind self to the given GinoEngine and return it.

If the given bind is a string or URL, all arguments will be sent to create_engine() to create a new engine, and return it.

Returns:GinoEngine
class gino.ext.sanic.GinoConnection(dialect, sa_conn, stack=None)[source]

Bases: gino.engine.GinoConnection

coroutine first_or_404(*args, **kwargs)[source]
class gino.ext.sanic.GinoEngine(dialect, pool, loop, logging_name=None, echo=None, execution_options=None)[source]

Bases: gino.engine.GinoEngine

connection_cls

alias of GinoConnection

coroutine first_or_404(*args, **kwargs)[source]
class gino.ext.sanic.GinoExecutor(query)[source]

Bases: gino.api.GinoExecutor

coroutine first_or_404(*args, **kwargs)[source]
class gino.ext.sanic.SanicModelMixin[source]

Bases: object

coroutine get_or_404(*args, **kwargs)[source]
class gino.ext.sanic.SanicStrategy[source]

Bases: gino.strategies.GinoStrategy

engine_cls

alias of GinoEngine

name = 'sanic'
gino.ext.sanic.disable_inherit(loop)
gino.ext.sanic.enable_inherit(loop)