gino.ext.sanic module

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

基类: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)
参数
  • bind -- A GinoEngine instance to bind. Also accepts string or URL, which will be passed to create_engine() when this Gino instance is awaited. Default is None.

  • model_classes -- A tuple of base class and mixin classes to create the Model class. Default is (CRUDModel, ).

  • query_ext -- Boolean value to control the installation of the gino extension on Executable for implicit execution. Default is to install (True).

  • schema_ext -- Boolean value to control the installation of the gino extension on SchemaItem for implicit execution. Default is to install (True).

  • ext -- Boolean value to control the installation of the two gino extensions. False for no extension at all, while it depends on the two individual switches when this is set to True (default).

  • kwargs -- Other arguments accepted by MetaData.

init_app(app)[源代码]
model_base_classes = (<class 'gino.crud.CRUDModel'>, <class 'gino.ext.sanic.SanicModelMixin'>)
query_executor

GinoExecutor 的别名

class gino.ext.sanic.GinoConnection(dialect, sa_conn, stack=None)[源代码]

基类:gino.engine.GinoConnection

class gino.ext.sanic.GinoEngine(dialect, pool, loop, logging_name=None, echo=None, execution_options=None)[源代码]

基类:gino.engine.GinoEngine

connection_cls

GinoConnection 的别名

class gino.ext.sanic.GinoExecutor(query)[源代码]

基类:gino.api.GinoExecutor

class gino.ext.sanic.SanicModelMixin[源代码]

基类:object

classmethod coroutine get_or_404(*args, **kwargs)[源代码]
class gino.ext.sanic.SanicStrategy[源代码]

基类:gino.strategies.GinoStrategy

engine_cls

GinoEngine 的别名

name = 'sanic'