gino.dialects.aiomysql module

class gino.dialects.aiomysql.AiomysqlDBAPI

Bases: gino.dialects.base.BaseDBAPI

paramstyle = 'format'
class gino.dialects.aiomysql.AiomysqlDialect(*args, bakery=None, **kwargs)

Bases: sqlalchemy.dialects.mysql.base.MySQLDialect, gino.dialects.base.AsyncDialectMixin

colspecs = {<class 'sqlalchemy.dialects.mysql.types._IntegerType'>: <class 'sqlalchemy.dialects.mysql.types._IntegerType'>, <class 'sqlalchemy.dialects.mysql.types._NumericType'>: <class 'sqlalchemy.dialects.mysql.types._NumericType'>, <class 'sqlalchemy.dialects.mysql.types._FloatType'>: <class 'sqlalchemy.dialects.mysql.types._FloatType'>, <class 'sqlalchemy.sql.sqltypes.Numeric'>: <class 'sqlalchemy.dialects.mysql.types.NUMERIC'>, <class 'sqlalchemy.sql.sqltypes.Float'>: <class 'sqlalchemy.dialects.mysql.types.FLOAT'>, <class 'sqlalchemy.sql.sqltypes.Time'>: <class 'sqlalchemy.dialects.mysql.types.TIME'>, <class 'sqlalchemy.sql.sqltypes.Enum'>: <class 'gino.dialects.aiomysql.AsyncEnum'>, <class 'sqlalchemy.sql.sqltypes.MatchType'>: <class 'sqlalchemy.dialects.mysql.types._MatchType'>, <class 'sqlalchemy.sql.sqltypes.JSON'>: <class 'sqlalchemy.dialects.mysql.json.JSON'>, <class 'sqlalchemy.sql.sqltypes.JSON.JSONIndexType'>: <class 'sqlalchemy.dialects.mysql.json.JSONIndexType'>, <class 'sqlalchemy.sql.sqltypes.JSON.JSONPathType'>: <class 'sqlalchemy.dialects.mysql.json.JSONPathType'>, <class 'sqlalchemy.dialects.mysql.enumerated.ENUM'>: <class 'gino.dialects.aiomysql.AsyncEnum'>, <class 'sqlalchemy.sql.sqltypes.NullType'>: <class 'gino.dialects.aiomysql.GinoNullType'>}
cursor_cls

alias of DBAPICursor

dbapi_class

alias of AiomysqlDBAPI

driver = 'aiomysql'
execution_ctx_cls

alias of AiomysqlExecutionContext

async get_isolation_level(connection)

Given a DBAPI connection, return its isolation level.

When working with a _engine.Connection object, the corresponding DBAPI connection may be procured using the _engine.Connection.connection accessor.

Note that this is a dialect-level method which is used as part of the implementation of the _engine.Connection and _engine.Engine isolation level facilities; these APIs should be preferred for most typical use cases.

See also

_engine.Connection.get_isolation_level() - view current level

_engine.Connection.default_isolation_level - view default level

:paramref:`.Connection.execution_options.isolation_level` - set per _engine.Connection isolation level

:paramref:`_sa.create_engine.isolation_level` - set per _engine.Engine isolation level

async has_table(connection, table_name, schema=None)

Check the existence of a particular table in the database.

Given a _engine.Connection object and a string table_name, return True if the given table (possibly within the specified schema) exists in the database, False otherwise.

init_kwargs = {'auth_plugin', 'autocommit', 'bakery', 'charset', 'client_flag', 'connect_timeout', 'conv', 'cursorclass', 'db', 'host', 'init_command', 'local_infile', 'loop', 'maxsize', 'minsize', 'no_delay', 'password', 'pool_recycle', 'port', 'prebake', 'program_name', 'read_default_file', 'read_default_group', 'server_public_key', 'sql_mode', 'ssl', 'unix_socket', 'use_unicode', 'user'}
async init_pool(url, loop, pool_class=None)
on_connect()

Return a callable which sets up a newly created DBAPI connection.

The callable should accept a single argument “conn” which is the DBAPI connection itself. The inner callable has no return value.

E.g.:

class MyDialect(default.DefaultDialect):
    # ...

    def on_connect(self):
        def do_on_connect(connection):
            connection.execute("SET SPECIAL FLAGS etc")

        return do_on_connect

This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc.

The “do_on_connect” callable is invoked by using the _events.PoolEvents.first_connect() and _events.PoolEvents.connect() event hooks, then unwrapping the DBAPI connection and passing it into the callable. The reason it is invoked for both events is so that any dialect-level initialization that occurs upon first connection, which also makes use of the _events.PoolEvents.first_connect() method, will proceed after this hook has been called. This currently means the hook is in fact called twice for the very first connection in which a dialect creates; and once per connection afterwards.

If None is returned, no event listener is generated.

Returns

a callable that accepts a single DBAPI connection as an argument, or None.

See also

Dialect.connect() - allows the DBAPI connect() sequence itself to be controlled.

postfetch_lastrowid = False
async set_isolation_level(connection, level)

Given a DBAPI connection, set its isolation level.

Note that this is a dialect-level method which is used as part of the implementation of the _engine.Connection and _engine.Engine isolation level facilities; these APIs should be preferred for most typical use cases.

See also

_engine.Connection.get_isolation_level() - view current level

_engine.Connection.default_isolation_level - view default level

:paramref:`.Connection.execution_options.isolation_level` - set per _engine.Connection isolation level

:paramref:`_sa.create_engine.isolation_level` - set per _engine.Engine isolation level

statement_compiler

alias of sqlalchemy.dialects.mysql.base.MySQLCompiler

support_prepare = False
support_returning = False
supports_native_decimal = True
transaction(raw_conn, args, kwargs)
class gino.dialects.aiomysql.AiomysqlExecutionContext

Bases: gino.dialects.base.ExecutionContextOverride, sqlalchemy.dialects.mysql.base.MySQLExecutionContext

get_affected_rows()
get_lastrowid()

return self.cursor.lastrowid, or equivalent, after an INSERT.

This may involve calling special cursor functions, issuing a new SELECT on the cursor (or a new one), or returning a stored value that was calculated within post_exec().

This function will only be called for dialects which support “implicit” primary key generation, keep preexecute_autoincrement_sequences set to False, and when no explicit id value was bound to the statement.

The function is called once, directly after post_exec() and before the transaction is committed or ResultProxy is generated. If the post_exec() method assigns a value to self._lastrowid, the value is used in place of calling get_lastrowid().

Note that this method is not equivalent to the lastrowid method on ResultProxy, which is a direct proxy to the DBAPI lastrowid accessor in all cases.

class gino.dialects.aiomysql.AiomysqlIterator(context, cursor)

Bases: gino.dialects.base.Cursor

async forward(n, *, timeout=<object object>)
async many(n, *, timeout=<object object>)
async next(*, timeout=<object object>)
class gino.dialects.aiomysql.AsyncEnum(*enums, **kw)

Bases: sqlalchemy.dialects.mysql.enumerated.ENUM

async create_async(bind=None, checkfirst=True)
async drop_async(bind=None, checkfirst=True)
class gino.dialects.aiomysql.DBAPICursor(dbapi_conn)

Bases: gino.dialects.base.DBAPICursor

async async_execute(query, timeout, args, limit=0, many=False)
property description
async execute_baked(baked_query, timeout, args, one)
get_statusmsg()
iterate(context)
async prepare(context, clause=None)
class gino.dialects.aiomysql.GinoNullType

Bases: sqlalchemy.sql.sqltypes.NullType

result_processor(dialect, coltype)

Return a conversion function for processing result row values.

Returns a callable which will receive a result row column value as the sole positional argument and will return a value to return to the user.

If processing is not necessary, the method should return None.

Parameters
  • dialect – Dialect instance in use.

  • coltype – DBAPI coltype argument received in cursor.description.

class gino.dialects.aiomysql.Pool(url, loop, init=None, bakery=None, prebake=True, **kwargs)

Bases: gino.dialects.base.Pool

async acquire(*, timeout=None)
async close()
property raw_pool
async release(conn)
repr(color)
class gino.dialects.aiomysql.Transaction(conn, set_isolation=None)

Bases: gino.dialects.base.Transaction

async begin()
async commit()
property raw_transaction
async rollback()