连接池

Other than the default connection pool, alternative pools can be used in their own use cases. There are options from dialects (currently only NullPool), and users can define their own pools. The base class should be Pool.

To use non-default pools in raw GINO:

  1. from gino.dialects.asyncpg import NullPool
  2. create_engine('postgresql://...', pool_class=NullPool)

To use non-default pools in extensions (taking Sanic as an example):

  1. from gino.dialects.asyncpg import NullPool
  2. from gino.ext.sanic import Gino
  3. app = sanic.Sanic()
  4. app.config.DB_HOST = 'localhost'
  5. app.config.DB_KWARGS = dict(
  6. pool_class=NullPool,
  7. )
  8. db = Gino()
  9. db.init_app(app)