L i#@ dZddlmZddlmZddlmZddlZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'dd l#m(Z(dd!l#m)Z)dd"l#m*Z*dd#l#m+Z+dd$l#m,Z,dd%l#m-Z-dd&l#m.Z.dd'l#m/Z/dd(l#m0Z0dd)l#m1Z1dd*l#m2Z2dd+l#m3Z3dd,l#m4Z4dd-l#m5Z5dd.l#m6Z6dd/l#m7Z7dd0l#m8Z8dd1l#m9Z9dd2l#m:Z:dd3l#m;Z;dd4l#mZ>dd7l#m?Z?dd8l#m@Z@dd9l#mAZAdd:l#mBZBd;dlmEZFd;d?lmGZGd;d@lmHZHd;dAlImJZKd;dBlImLZLd;dlImZd;dClMmNZNd;dDlGmOZOd;dElGmPZPd;dFlGmQZQd;dGlGmRZRd;dHlGmSZSd;dIlGmTZTd;dJlGmUZUd;d@lGmHZVd;dKlGmWZWd;dLlXmYZYd;dMlXmZZZd;dNl[m\Z\d;dOl#m]Z]d;dPl#m^Z^d;dQl#m_Z_d;dRl#m`Z`d;dSl#maZad;dTl#mbZbd;dUl#mcZcd;dVlHmdZderd;dWlemfZfd;dXlgmhZhd;dYlimjZjd;dZlkmlZld;d[lmmnZnd;d\lmmoZod;d]lmmpZpd;d^lmmqZqd;d_lmmrZrd;d`lmmsZsd;dalmmtZtd;dblmmuZud;dclmmvZvd;ddlmmwZwd;delmmxZxd;dflmmyZyd;dglzm{Z{d;dhl|m}Z}d;dilEm~Z~d;djlGmZd;dklGmZd;dllmZd;dmlmZd;dnlmZd;dolmZd;dplmZd;dqlmZd;drlmZd;dslmZd;dl[mZd;dtlmZd;dulmZej dvej"ej$zZeZe^Ze]ZecZe6Ze8Ze+ZeAZe2Ze5Ze@Ze;ZeBZe=Ze*Ze:Ze?Ze4Ze)Ze7Ze-Ze.Ze9Ze/Ze0Ze%e%e'e'e$e$eUjde7eUjfe/eUjhe.eUjjeei Zidwe)dxe]dye*dze^d{e_d|e+d}e`d~e,de-de.dede-de/de0de0dede1ide2de3de4de5de6de8de7dede:de;de<de=de>de?de@debdeceAeBdZGddeLjtZGddePjZGddePjzZGddePj~ZGddePjZGdde«ZGddeLjZGddZeGjdeGjdeAdeGjdeAdeGjdeAdd>Zy)aߕ .. dialect:: mysql :name: MySQL / MariaDB :normal_support: 5.6+ / 10+ :best_effort: 5.0.2+ / 5.0.2+ Supported Versions and Features ------------------------------- SQLAlchemy supports MySQL starting with version 5.0.2 through modern releases, as well as all modern versions of MariaDB. See the official MySQL documentation for detailed information about features supported in any given server release. .. versionchanged:: 1.4 minimum MySQL version supported is now 5.0.2. MariaDB Support ~~~~~~~~~~~~~~~ The MariaDB variant of MySQL retains fundamental compatibility with MySQL's protocols however the development of these two products continues to diverge. Within the realm of SQLAlchemy, the two databases have a small number of syntactical and behavioral differences that SQLAlchemy accommodates automatically. To connect to a MariaDB database, no changes to the database URL are required:: engine = create_engine( "mysql+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4" ) Upon first connect, the SQLAlchemy dialect employs a server version detection scheme that determines if the backing database reports as MariaDB. Based on this flag, the dialect can make different choices in those of areas where its behavior must be different. .. _mysql_mariadb_only_mode: MariaDB-Only Mode ~~~~~~~~~~~~~~~~~ The dialect also supports an **optional** "MariaDB-only" mode of connection, which may be useful for the case where an application makes use of MariaDB-specific features and is not compatible with a MySQL database. To use this mode of operation, replace the "mysql" token in the above URL with "mariadb":: engine = create_engine( "mariadb+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4" ) The above engine, upon first connect, will raise an error if the server version detection detects that the backing database is not MariaDB. When using an engine with ``"mariadb"`` as the dialect name, **all mysql-specific options that include the name "mysql" in them are now named with "mariadb"**. This means options like ``mysql_engine`` should be named ``mariadb_engine``, etc. Both "mysql" and "mariadb" options can be used simultaneously for applications that use URLs with both "mysql" and "mariadb" dialects:: my_table = Table( "mytable", metadata, Column("id", Integer, primary_key=True), Column("textdata", String(50)), mariadb_engine="InnoDB", mysql_engine="InnoDB", ) Index( "textdata_ix", my_table.c.textdata, mysql_prefix="FULLTEXT", mariadb_prefix="FULLTEXT", ) Similar behavior will occur when the above structures are reflected, i.e. the "mariadb" prefix will be present in the option names when the database URL is based on the "mariadb" name. .. versionadded:: 1.4 Added "mariadb" dialect name supporting "MariaDB-only mode" for the MySQL dialect. .. _mysql_connection_timeouts: Connection Timeouts and Disconnects ----------------------------------- MySQL / MariaDB feature an automatic connection close behavior, for connections that have been idle for a fixed period of time, defaulting to eight hours. To circumvent having this issue, use the :paramref:`_sa.create_engine.pool_recycle` option which ensures that a connection will be discarded and replaced with a new one if it has been present in the pool for a fixed number of seconds:: engine = create_engine("mysql+mysqldb://...", pool_recycle=3600) For more comprehensive disconnect detection of pooled connections, including accommodation of server restarts and network issues, a pre-ping approach may be employed. See :ref:`pool_disconnects` for current approaches. .. seealso:: :ref:`pool_disconnects` - Background on several techniques for dealing with timed out connections as well as database restarts. .. _mysql_storage_engines: CREATE TABLE arguments including Storage Engines ------------------------------------------------ Both MySQL's and MariaDB's CREATE TABLE syntax includes a wide array of special options, including ``ENGINE``, ``CHARSET``, ``MAX_ROWS``, ``ROW_FORMAT``, ``INSERT_METHOD``, and many more. To accommodate the rendering of these arguments, specify the form ``mysql_argument_name="value"``. For example, to specify a table with ``ENGINE`` of ``InnoDB``, ``CHARSET`` of ``utf8mb4``, and ``KEY_BLOCK_SIZE`` of ``1024``:: Table( "mytable", metadata, Column("data", String(32)), mysql_engine="InnoDB", mysql_charset="utf8mb4", mysql_key_block_size="1024", ) When supporting :ref:`mysql_mariadb_only_mode` mode, similar keys against the "mariadb" prefix must be included as well. The values can of course vary independently so that different settings on MySQL vs. MariaDB may be maintained:: # support both "mysql" and "mariadb-only" engine URLs Table( "mytable", metadata, Column("data", String(32)), mysql_engine="InnoDB", mariadb_engine="InnoDB", mysql_charset="utf8mb4", mariadb_charset="utf8", mysql_key_block_size="1024", mariadb_key_block_size="1024", ) The MySQL / MariaDB dialects will normally transfer any keyword specified as ``mysql_keyword_name`` to be rendered as ``KEYWORD_NAME`` in the ``CREATE TABLE`` statement. A handful of these names will render with a space instead of an underscore; to support this, the MySQL dialect has awareness of these particular names, which include ``DATA DIRECTORY`` (e.g. ``mysql_data_directory``), ``CHARACTER SET`` (e.g. ``mysql_character_set``) and ``INDEX DIRECTORY`` (e.g. ``mysql_index_directory``). The most common argument is ``mysql_engine``, which refers to the storage engine for the table. Historically, MySQL server installations would default to ``MyISAM`` for this value, although newer versions may be defaulting to ``InnoDB``. The ``InnoDB`` engine is typically preferred for its support of transactions and foreign keys. A :class:`_schema.Table` that is created in a MySQL / MariaDB database with a storage engine of ``MyISAM`` will be essentially non-transactional, meaning any INSERT/UPDATE/DELETE statement referring to this table will be invoked as autocommit. It also will have no support for foreign key constraints; while the ``CREATE TABLE`` statement accepts foreign key options, when using the ``MyISAM`` storage engine these arguments are discarded. Reflecting such a table will also produce no foreign key constraint information. For fully atomic transactions as well as support for foreign key constraints, all participating ``CREATE TABLE`` statements must specify a transactional engine, which in the vast majority of cases is ``InnoDB``. Partitioning can similarly be specified using similar options. In the example below the create table will specify ``PARTITION_BY``, ``PARTITIONS``, ``SUBPARTITIONS`` and ``SUBPARTITION_BY``:: # can also use mariadb_* prefix Table( "testtable", MetaData(), Column("id", Integer(), primary_key=True, autoincrement=True), Column("other_id", Integer(), primary_key=True, autoincrement=False), mysql_partitions="2", mysql_partition_by="KEY(other_id)", mysql_subpartition_by="HASH(some_expr)", mysql_subpartitions="2", ) This will render: .. sourcecode:: sql CREATE TABLE testtable ( id INTEGER NOT NULL AUTO_INCREMENT, other_id INTEGER NOT NULL, PRIMARY KEY (id, other_id) )PARTITION BY KEY(other_id) PARTITIONS 2 SUBPARTITION BY HASH(some_expr) SUBPARTITIONS 2 Case Sensitivity and Table Reflection ------------------------------------- Both MySQL and MariaDB have inconsistent support for case-sensitive identifier names, basing support on specific details of the underlying operating system. However, it has been observed that no matter what case sensitivity behavior is present, the names of tables in foreign key declarations are *always* received from the database as all-lower case, making it impossible to accurately reflect a schema where inter-related tables use mixed-case identifier names. Therefore it is strongly advised that table names be declared as all lower case both within SQLAlchemy as well as on the MySQL / MariaDB database itself, especially if database reflection features are to be used. .. _mysql_isolation_level: Transaction Isolation Level --------------------------- All MySQL / MariaDB dialects support setting of transaction isolation level both via a dialect-specific parameter :paramref:`_sa.create_engine.isolation_level` accepted by :func:`_sa.create_engine`, as well as the :paramref:`.Connection.execution_options.isolation_level` argument as passed to :meth:`_engine.Connection.execution_options`. This feature works by issuing the command ``SET SESSION TRANSACTION ISOLATION LEVEL `` for each new connection. For the special AUTOCOMMIT isolation level, DBAPI-specific techniques are used. To set isolation level using :func:`_sa.create_engine`:: engine = create_engine( "mysql+mysqldb://scott:tiger@localhost/test", isolation_level="READ UNCOMMITTED", ) To set using per-connection execution options:: connection = engine.connect() connection = connection.execution_options(isolation_level="READ COMMITTED") Valid values for ``isolation_level`` include: * ``READ COMMITTED`` * ``READ UNCOMMITTED`` * ``REPEATABLE READ`` * ``SERIALIZABLE`` * ``AUTOCOMMIT`` The special ``AUTOCOMMIT`` value makes use of the various "autocommit" attributes provided by specific DBAPIs, and is currently supported by MySQLdb, MySQL-Client, MySQL-Connector Python, and PyMySQL. Using it, the database connection will return true for the value of ``SELECT @@autocommit;``. There are also more options for isolation level configurations, such as "sub-engine" objects linked to a main :class:`_engine.Engine` which each apply different isolation level settings. See the discussion at :ref:`dbapi_autocommit` for background. .. seealso:: :ref:`dbapi_autocommit` AUTO_INCREMENT Behavior ----------------------- When creating tables, SQLAlchemy will automatically set ``AUTO_INCREMENT`` on the first :class:`.Integer` primary key column which is not marked as a foreign key:: >>> t = Table( ... "mytable", metadata, Column("mytable_id", Integer, primary_key=True) ... ) >>> t.create() CREATE TABLE mytable ( id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) You can disable this behavior by passing ``False`` to the :paramref:`_schema.Column.autoincrement` argument of :class:`_schema.Column`. This flag can also be used to enable auto-increment on a secondary column in a multi-column key for some storage engines:: Table( "mytable", metadata, Column("gid", Integer, primary_key=True, autoincrement=False), Column("id", Integer, primary_key=True), ) .. _mysql_ss_cursors: Server Side Cursors ------------------- Server-side cursor support is available for the mysqlclient, PyMySQL, mariadbconnector dialects and may also be available in others. This makes use of either the "buffered=True/False" flag if available or by using a class such as ``MySQLdb.cursors.SSCursor`` or ``pymysql.cursors.SSCursor`` internally. Server side cursors are enabled on a per-statement basis by using the :paramref:`.Connection.execution_options.stream_results` connection execution option:: with engine.connect() as conn: result = conn.execution_options(stream_results=True).execute( text("select * from table") ) Note that some kinds of SQL statements may not be supported with server side cursors; generally, only SQL statements that return rows should be used with this option. .. deprecated:: 1.4 The dialect-level server_side_cursors flag is deprecated and will be removed in a future release. Please use the :paramref:`_engine.Connection.stream_results` execution option for unbuffered cursor support. .. seealso:: :ref:`engine_stream_results` .. _mysql_unicode: Unicode ------- Charset Selection ~~~~~~~~~~~~~~~~~ Most MySQL / MariaDB DBAPIs offer the option to set the client character set for a connection. This is typically delivered using the ``charset`` parameter in the URL, such as:: e = create_engine( "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4" ) This charset is the **client character set** for the connection. Some MySQL DBAPIs will default this to a value such as ``latin1``, and some will make use of the ``default-character-set`` setting in the ``my.cnf`` file as well. Documentation for the DBAPI in use should be consulted for specific behavior. The encoding used for Unicode has traditionally been ``'utf8'``. However, for MySQL versions 5.5.3 and MariaDB 5.5 on forward, a new MySQL-specific encoding ``'utf8mb4'`` has been introduced, and as of MySQL 8.0 a warning is emitted by the server if plain ``utf8`` is specified within any server-side directives, replaced with ``utf8mb3``. The rationale for this new encoding is due to the fact that MySQL's legacy utf-8 encoding only supports codepoints up to three bytes instead of four. Therefore, when communicating with a MySQL or MariaDB database that includes codepoints more than three bytes in size, this new charset is preferred, if supported by both the database as well as the client DBAPI, as in:: e = create_engine( "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4" ) All modern DBAPIs should support the ``utf8mb4`` charset. In order to use ``utf8mb4`` encoding for a schema that was created with legacy ``utf8``, changes to the MySQL/MariaDB schema and/or server configuration may be required. .. seealso:: `The utf8mb4 Character Set \ `_ - \ in the MySQL documentation .. _mysql_binary_introducer: Dealing with Binary Data Warnings and Unicode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MySQL versions 5.6, 5.7 and later (not MariaDB at the time of this writing) now emit a warning when attempting to pass binary data to the database, while a character set encoding is also in place, when the binary data itself is not valid for that encoding: .. sourcecode:: text default.py:509: Warning: (1300, "Invalid utf8mb4 character string: 'F9876A'") cursor.execute(statement, parameters) This warning is due to the fact that the MySQL client library is attempting to interpret the binary string as a unicode object even if a datatype such as :class:`.LargeBinary` is in use. To resolve this, the SQL statement requires a binary "character set introducer" be present before any non-NULL value that renders like this: .. sourcecode:: sql INSERT INTO table (data) VALUES (_binary %s) These character set introducers are provided by the DBAPI driver, assuming the use of mysqlclient or PyMySQL (both of which are recommended). Add the query string parameter ``binary_prefix=true`` to the URL to repair this warning:: # mysqlclient engine = create_engine( "mysql+mysqldb://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true" ) # PyMySQL engine = create_engine( "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true" ) The ``binary_prefix`` flag may or may not be supported by other MySQL drivers. SQLAlchemy itself cannot render this ``_binary`` prefix reliably, as it does not work with the NULL value, which is valid to be sent as a bound parameter. As the MySQL driver renders parameters directly into the SQL string, it's the most efficient place for this additional keyword to be passed. .. seealso:: `Character set introducers `_ - on the MySQL website ANSI Quoting Style ------------------ MySQL / MariaDB feature two varieties of identifier "quoting style", one using backticks and the other using quotes, e.g. ```some_identifier``` vs. ``"some_identifier"``. All MySQL dialects detect which version is in use by checking the value of :ref:`sql_mode` when a connection is first established with a particular :class:`_engine.Engine`. This quoting style comes into play when rendering table and column names as well as when reflecting existing database structures. The detection is entirely automatic and no special configuration is needed to use either quoting style. .. _mysql_sql_mode: Changing the sql_mode --------------------- MySQL supports operating in multiple `Server SQL Modes `_ for both Servers and Clients. To change the ``sql_mode`` for a given application, a developer can leverage SQLAlchemy's Events system. In the following example, the event system is used to set the ``sql_mode`` on the ``first_connect`` and ``connect`` events:: from sqlalchemy import create_engine, event eng = create_engine( "mysql+mysqldb://scott:tiger@localhost/test", echo="debug" ) # `insert=True` will ensure this is the very first listener to run @event.listens_for(eng, "connect", insert=True) def connect(dbapi_connection, connection_record): cursor = dbapi_connection.cursor() cursor.execute("SET sql_mode = 'STRICT_ALL_TABLES'") conn = eng.connect() In the example illustrated above, the "connect" event will invoke the "SET" statement on the connection at the moment a particular DBAPI connection is first created for a given Pool, before the connection is made available to the connection pool. Additionally, because the function was registered with ``insert=True``, it will be prepended to the internal list of registered functions. MySQL / MariaDB SQL Extensions ------------------------------ Many of the MySQL / MariaDB SQL extensions are handled through SQLAlchemy's generic function and operator support:: table.select(table.c.password == func.md5("plaintext")) table.select(table.c.username.op("regexp")("^[a-d]")) And of course any valid SQL statement can be executed as a string as well. Some limited direct support for MySQL / MariaDB extensions to SQL is currently available. * INSERT..ON DUPLICATE KEY UPDATE: See :ref:`mysql_insert_on_duplicate_key_update` * SELECT pragma, use :meth:`_expression.Select.prefix_with` and :meth:`_query.Query.prefix_with`:: select(...).prefix_with(["HIGH_PRIORITY", "SQL_SMALL_RESULT"]) * UPDATE with LIMIT:: update(...).with_dialect_options(mysql_limit=10, mariadb_limit=10) * DELETE with LIMIT:: delete(...).with_dialect_options(mysql_limit=10, mariadb_limit=10) .. versionadded:: 2.0.37 Added delete with limit * optimizer hints, use :meth:`_expression.Select.prefix_with` and :meth:`_query.Query.prefix_with`:: select(...).prefix_with("/*+ NO_RANGE_OPTIMIZATION(t4 PRIMARY) */") * index hints, use :meth:`_expression.Select.with_hint` and :meth:`_query.Query.with_hint`:: select(...).with_hint(some_table, "USE INDEX xyz") * MATCH operator support:: from sqlalchemy.dialects.mysql import match select(...).where(match(col1, col2, against="some expr").in_boolean_mode()) .. seealso:: :class:`_mysql.match` INSERT/DELETE...RETURNING ------------------------- The MariaDB dialect supports 10.5+'s ``INSERT..RETURNING`` and ``DELETE..RETURNING`` (10.0+) syntaxes. ``INSERT..RETURNING`` may be used automatically in some cases in order to fetch newly generated identifiers in place of the traditional approach of using ``cursor.lastrowid``, however ``cursor.lastrowid`` is currently still preferred for simple single-statement cases for its better performance. To specify an explicit ``RETURNING`` clause, use the :meth:`._UpdateBase.returning` method on a per-statement basis:: # INSERT..RETURNING result = connection.execute( table.insert().values(name="foo").returning(table.c.col1, table.c.col2) ) print(result.all()) # DELETE..RETURNING result = connection.execute( table.delete() .where(table.c.name == "foo") .returning(table.c.col1, table.c.col2) ) print(result.all()) .. versionadded:: 2.0 Added support for MariaDB RETURNING .. _mysql_insert_on_duplicate_key_update: INSERT...ON DUPLICATE KEY UPDATE (Upsert) ------------------------------------------ MySQL / MariaDB allow "upserts" (update or insert) of rows into a table via the ``ON DUPLICATE KEY UPDATE`` clause of the ``INSERT`` statement. A candidate row will only be inserted if that row does not match an existing primary or unique key in the table; otherwise, an UPDATE will be performed. The statement allows for separate specification of the values to INSERT versus the values for UPDATE. SQLAlchemy provides ``ON DUPLICATE KEY UPDATE`` support via the MySQL-specific :func:`.mysql.insert()` function, which provides the generative method :meth:`~.mysql.Insert.on_duplicate_key_update`: .. sourcecode:: pycon+sql >>> from sqlalchemy.dialects.mysql import insert >>> insert_stmt = insert(my_table).values( ... id="some_existing_id", data="inserted value" ... ) >>> on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update( ... data=insert_stmt.inserted.data, status="U" ... ) >>> print(on_duplicate_key_stmt) {printsql}INSERT INTO my_table (id, data) VALUES (%s, %s) ON DUPLICATE KEY UPDATE data = VALUES(data), status = %s Unlike PostgreSQL's "ON CONFLICT" phrase, the "ON DUPLICATE KEY UPDATE" phrase will always match on any primary key or unique key, and will always perform an UPDATE if there's a match; there are no options for it to raise an error or to skip performing an UPDATE. ``ON DUPLICATE KEY UPDATE`` is used to perform an update of the already existing row, using any combination of new values as well as values from the proposed insertion. These values are normally specified using keyword arguments passed to the :meth:`_mysql.Insert.on_duplicate_key_update` given column key values (usually the name of the column, unless it specifies :paramref:`_schema.Column.key` ) as keys and literal or SQL expressions as values: .. sourcecode:: pycon+sql >>> insert_stmt = insert(my_table).values( ... id="some_existing_id", data="inserted value" ... ) >>> on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update( ... data="some data", ... updated_at=func.current_timestamp(), ... ) >>> print(on_duplicate_key_stmt) {printsql}INSERT INTO my_table (id, data) VALUES (%s, %s) ON DUPLICATE KEY UPDATE data = %s, updated_at = CURRENT_TIMESTAMP In a manner similar to that of :meth:`.UpdateBase.values`, other parameter forms are accepted, including a single dictionary: .. sourcecode:: pycon+sql >>> on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update( ... {"data": "some data", "updated_at": func.current_timestamp()}, ... ) as well as a list of 2-tuples, which will automatically provide a parameter-ordered UPDATE statement in a manner similar to that described at :ref:`tutorial_parameter_ordered_updates`. Unlike the :class:`_expression.Update` object, no special flag is needed to specify the intent since the argument form is this context is unambiguous: .. sourcecode:: pycon+sql >>> on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update( ... [ ... ("data", "some data"), ... ("updated_at", func.current_timestamp()), ... ] ... ) >>> print(on_duplicate_key_stmt) {printsql}INSERT INTO my_table (id, data) VALUES (%s, %s) ON DUPLICATE KEY UPDATE data = %s, updated_at = CURRENT_TIMESTAMP .. versionchanged:: 1.3 support for parameter-ordered UPDATE clause within MySQL ON DUPLICATE KEY UPDATE .. warning:: The :meth:`_mysql.Insert.on_duplicate_key_update` method does **not** take into account Python-side default UPDATE values or generation functions, e.g. e.g. those specified using :paramref:`_schema.Column.onupdate`. These values will not be exercised for an ON DUPLICATE KEY style of UPDATE, unless they are manually specified explicitly in the parameters. In order to refer to the proposed insertion row, the special alias :attr:`_mysql.Insert.inserted` is available as an attribute on the :class:`_mysql.Insert` object; this object is a :class:`_expression.ColumnCollection` which contains all columns of the target table: .. sourcecode:: pycon+sql >>> stmt = insert(my_table).values( ... id="some_id", data="inserted value", author="jlh" ... ) >>> do_update_stmt = stmt.on_duplicate_key_update( ... data="updated value", author=stmt.inserted.author ... ) >>> print(do_update_stmt) {printsql}INSERT INTO my_table (id, data, author) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE data = %s, author = VALUES(author) When rendered, the "inserted" namespace will produce the expression ``VALUES()``. .. versionadded:: 1.2 Added support for MySQL ON DUPLICATE KEY UPDATE clause rowcount Support ---------------- SQLAlchemy standardizes the DBAPI ``cursor.rowcount`` attribute to be the usual definition of "number of rows matched by an UPDATE or DELETE" statement. This is in contradiction to the default setting on most MySQL DBAPI drivers, which is "number of rows actually modified/deleted". For this reason, the SQLAlchemy MySQL dialects always add the ``constants.CLIENT.FOUND_ROWS`` flag, or whatever is equivalent for the target dialect, upon connection. This setting is currently hardcoded. .. seealso:: :attr:`_engine.CursorResult.rowcount` .. _mysql_indexes: MySQL / MariaDB- Specific Index Options ----------------------------------------- MySQL and MariaDB-specific extensions to the :class:`.Index` construct are available. Index Length ~~~~~~~~~~~~~ MySQL and MariaDB both provide an option to create index entries with a certain length, where "length" refers to the number of characters or bytes in each value which will become part of the index. SQLAlchemy provides this feature via the ``mysql_length`` and/or ``mariadb_length`` parameters:: Index("my_index", my_table.c.data, mysql_length=10, mariadb_length=10) Index("a_b_idx", my_table.c.a, my_table.c.b, mysql_length={"a": 4, "b": 9}) Index( "a_b_idx", my_table.c.a, my_table.c.b, mariadb_length={"a": 4, "b": 9} ) Prefix lengths are given in characters for nonbinary string types and in bytes for binary string types. The value passed to the keyword argument *must* be either an integer (and, thus, specify the same prefix length value for all columns of the index) or a dict in which keys are column names and values are prefix length values for corresponding columns. MySQL and MariaDB only allow a length for a column of an index if it is for a CHAR, VARCHAR, TEXT, BINARY, VARBINARY and BLOB. Index Prefixes ~~~~~~~~~~~~~~ MySQL storage engines permit you to specify an index prefix when creating an index. SQLAlchemy provides this feature via the ``mysql_prefix`` parameter on :class:`.Index`:: Index("my_index", my_table.c.data, mysql_prefix="FULLTEXT") The value passed to the keyword argument will be simply passed through to the underlying CREATE INDEX, so it *must* be a valid index prefix for your MySQL storage engine. .. seealso:: `CREATE INDEX `_ - MySQL documentation Index Types ~~~~~~~~~~~~~ Some MySQL storage engines permit you to specify an index type when creating an index or primary key constraint. SQLAlchemy provides this feature via the ``mysql_using`` parameter on :class:`.Index`:: Index( "my_index", my_table.c.data, mysql_using="hash", mariadb_using="hash" ) As well as the ``mysql_using`` parameter on :class:`.PrimaryKeyConstraint`:: PrimaryKeyConstraint("data", mysql_using="hash", mariadb_using="hash") The value passed to the keyword argument will be simply passed through to the underlying CREATE INDEX or PRIMARY KEY clause, so it *must* be a valid index type for your MySQL storage engine. More information can be found at: https://dev.mysql.com/doc/refman/5.0/en/create-index.html https://dev.mysql.com/doc/refman/5.0/en/create-table.html Index Parsers ~~~~~~~~~~~~~ CREATE FULLTEXT INDEX in MySQL also supports a "WITH PARSER" option. This is available using the keyword argument ``mysql_with_parser``:: Index( "my_index", my_table.c.data, mysql_prefix="FULLTEXT", mysql_with_parser="ngram", mariadb_prefix="FULLTEXT", mariadb_with_parser="ngram", ) .. versionadded:: 1.3 .. _mysql_foreign_keys: MySQL / MariaDB Foreign Keys ----------------------------- MySQL and MariaDB's behavior regarding foreign keys has some important caveats. Foreign Key Arguments to Avoid ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Neither MySQL nor MariaDB support the foreign key arguments "DEFERRABLE", "INITIALLY", or "MATCH". Using the ``deferrable`` or ``initially`` keyword argument with :class:`_schema.ForeignKeyConstraint` or :class:`_schema.ForeignKey` will have the effect of these keywords being rendered in a DDL expression, which will then raise an error on MySQL or MariaDB. In order to use these keywords on a foreign key while having them ignored on a MySQL / MariaDB backend, use a custom compile rule:: from sqlalchemy.ext.compiler import compiles from sqlalchemy.schema import ForeignKeyConstraint @compiles(ForeignKeyConstraint, "mysql", "mariadb") def process(element, compiler, **kw): element.deferrable = element.initially = None return compiler.visit_foreign_key_constraint(element, **kw) The "MATCH" keyword is in fact more insidious, and is explicitly disallowed by SQLAlchemy in conjunction with the MySQL or MariaDB backends. This argument is silently ignored by MySQL / MariaDB, but in addition has the effect of ON UPDATE and ON DELETE options also being ignored by the backend. Therefore MATCH should never be used with the MySQL / MariaDB backends; as is the case with DEFERRABLE and INITIALLY, custom compilation rules can be used to correct a ForeignKeyConstraint at DDL definition time. Reflection of Foreign Key Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Not all MySQL / MariaDB storage engines support foreign keys. When using the very common ``MyISAM`` MySQL storage engine, the information loaded by table reflection will not include foreign keys. For these tables, you may supply a :class:`~sqlalchemy.ForeignKeyConstraint` at reflection time:: Table( "mytable", metadata, ForeignKeyConstraint(["other_id"], ["othertable.other_id"]), autoload_with=engine, ) .. seealso:: :ref:`mysql_storage_engines` .. _mysql_unique_constraints: MySQL / MariaDB Unique Constraints and Reflection ---------------------------------------------------- SQLAlchemy supports both the :class:`.Index` construct with the flag ``unique=True``, indicating a UNIQUE index, as well as the :class:`.UniqueConstraint` construct, representing a UNIQUE constraint. Both objects/syntaxes are supported by MySQL / MariaDB when emitting DDL to create these constraints. However, MySQL / MariaDB does not have a unique constraint construct that is separate from a unique index; that is, the "UNIQUE" constraint on MySQL / MariaDB is equivalent to creating a "UNIQUE INDEX". When reflecting these constructs, the :meth:`_reflection.Inspector.get_indexes` and the :meth:`_reflection.Inspector.get_unique_constraints` methods will **both** return an entry for a UNIQUE index in MySQL / MariaDB. However, when performing full table reflection using ``Table(..., autoload_with=engine)``, the :class:`.UniqueConstraint` construct is **not** part of the fully reflected :class:`_schema.Table` construct under any circumstances; this construct is always represented by a :class:`.Index` with the ``unique=True`` setting present in the :attr:`_schema.Table.indexes` collection. TIMESTAMP / DATETIME issues --------------------------- .. _mysql_timestamp_onupdate: Rendering ON UPDATE CURRENT TIMESTAMP for MySQL / MariaDB's explicit_defaults_for_timestamp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MySQL / MariaDB have historically expanded the DDL for the :class:`_types.TIMESTAMP` datatype into the phrase "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", which includes non-standard SQL that automatically updates the column with the current timestamp when an UPDATE occurs, eliminating the usual need to use a trigger in such a case where server-side update changes are desired. MySQL 5.6 introduced a new flag `explicit_defaults_for_timestamp `_ which disables the above behavior, and in MySQL 8 this flag defaults to true, meaning in order to get a MySQL "on update timestamp" without changing this flag, the above DDL must be rendered explicitly. Additionally, the same DDL is valid for use of the ``DATETIME`` datatype as well. SQLAlchemy's MySQL dialect does not yet have an option to generate MySQL's "ON UPDATE CURRENT_TIMESTAMP" clause, noting that this is not a general purpose "ON UPDATE" as there is no such syntax in standard SQL. SQLAlchemy's :paramref:`_schema.Column.server_onupdate` parameter is currently not related to this special MySQL behavior. To generate this DDL, make use of the :paramref:`_schema.Column.server_default` parameter and pass a textual clause that also includes the ON UPDATE clause:: from sqlalchemy import Table, MetaData, Column, Integer, String, TIMESTAMP from sqlalchemy import text metadata = MetaData() mytable = Table( "mytable", metadata, Column("id", Integer, primary_key=True), Column("data", String(50)), Column( "last_updated", TIMESTAMP, server_default=text( "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" ), ), ) The same instructions apply to use of the :class:`_types.DateTime` and :class:`_types.DATETIME` datatypes:: from sqlalchemy import DateTime mytable = Table( "mytable", metadata, Column("id", Integer, primary_key=True), Column("data", String(50)), Column( "last_updated", DateTime, server_default=text( "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" ), ), ) Even though the :paramref:`_schema.Column.server_onupdate` feature does not generate this DDL, it still may be desirable to signal to the ORM that this updated value should be fetched. This syntax looks like the following:: from sqlalchemy.schema import FetchedValue class MyClass(Base): __tablename__ = "mytable" id = Column(Integer, primary_key=True) data = Column(String(50)) last_updated = Column( TIMESTAMP, server_default=text( "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" ), server_onupdate=FetchedValue(), ) .. _mysql_timestamp_null: TIMESTAMP Columns and NULL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MySQL historically enforces that a column which specifies the TIMESTAMP datatype implicitly includes a default value of CURRENT_TIMESTAMP, even though this is not stated, and additionally sets the column as NOT NULL, the opposite behavior vs. that of all other datatypes: .. sourcecode:: text mysql> CREATE TABLE ts_test ( -> a INTEGER, -> b INTEGER NOT NULL, -> c TIMESTAMP, -> d TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -> e TIMESTAMP NULL); Query OK, 0 rows affected (0.03 sec) mysql> SHOW CREATE TABLE ts_test; +---------+----------------------------------------------------- | Table | Create Table +---------+----------------------------------------------------- | ts_test | CREATE TABLE `ts_test` ( `a` int(11) DEFAULT NULL, `b` int(11) NOT NULL, `c` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `e` timestamp NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Above, we see that an INTEGER column defaults to NULL, unless it is specified with NOT NULL. But when the column is of type TIMESTAMP, an implicit default of CURRENT_TIMESTAMP is generated which also coerces the column to be a NOT NULL, even though we did not specify it as such. This behavior of MySQL can be changed on the MySQL side using the `explicit_defaults_for_timestamp `_ configuration flag introduced in MySQL 5.6. With this server setting enabled, TIMESTAMP columns behave like any other datatype on the MySQL side with regards to defaults and nullability. However, to accommodate the vast majority of MySQL databases that do not specify this new flag, SQLAlchemy emits the "NULL" specifier explicitly with any TIMESTAMP column that does not specify ``nullable=False``. In order to accommodate newer databases that specify ``explicit_defaults_for_timestamp``, SQLAlchemy also emits NOT NULL for TIMESTAMP columns that do specify ``nullable=False``. The following example illustrates:: from sqlalchemy import MetaData, Integer, Table, Column, text from sqlalchemy.dialects.mysql import TIMESTAMP m = MetaData() t = Table( "ts_test", m, Column("a", Integer), Column("b", Integer, nullable=False), Column("c", TIMESTAMP), Column("d", TIMESTAMP, nullable=False), ) from sqlalchemy import create_engine e = create_engine("mysql+mysqldb://scott:tiger@localhost/test", echo=True) m.create_all(e) output: .. sourcecode:: sql CREATE TABLE ts_test ( a INTEGER, b INTEGER NOT NULL, c TIMESTAMP NULL, d TIMESTAMP NOT NULL ) ) annotations) defaultdict)compressN)Any)Callable)cast) DefaultDict)Dict)List)NoReturn)Optional)overload)Sequence)Tuple) TYPE_CHECKING)Union) reflection)ENUM)SET)JSON) JSONIndexType) JSONPathType)RESERVED_WORDS_MARIADB)RESERVED_WORDS_MYSQL) _FloatType) _IntegerType) _MatchType) _NumericType) _StringType)BIGINT)BIT)CHAR)DATETIME)DECIMAL)DOUBLE)FLOAT)INTEGER)LONGBLOB)LONGTEXT) MEDIUMBLOB) MEDIUMINT) MEDIUMTEXT)NCHAR)NUMERIC)NVARCHAR)REAL)SMALLINT)TEXT)TIME) TIMESTAMP)TINYBLOB)TINYINT)TINYTEXT)VARCHAR)YEAR)exc)literal_column)schema)sql)util)cursor)default)ReflectionDefaults) coercions)compiler)elements) functions) operators)roles)sqltypes)visitors)InsertmanyvaluesSentinelOpts) SQLCompiler) SchemaConst)BINARY)BLOB)BOOLEAN)DATE) LargeBinary)UUID) VARBINARY) topological) expression)OnDuplicateClause) Connection) CursorResult)DBAPIConnection) DBAPICursor) DBAPIModule)IsolationLevel)PoolProxiedConnection)ReflectedCheckConstraint)ReflectedColumn)ReflectedForeignKeyConstraint)ReflectedIndex)ReflectedPrimaryKeyConstraint)ReflectedTableComment)ReflectedUniqueConstraint)Row)URL)Table)ddl) selectable)_DMLTableElement)Delete)Update) ValuesBase)aggregate_strings)random)rollup)sysdate) TypeEngine)ExternallyTraversiblez%\s*SET\s+(?:(?:GLOBAL|SESSION)\s+)?\wbigintbinarybitblobbooleanchardatedatetimedecimaldoubleenumfixedfloatintintegerjsonlongbloblongtext mediumblob mediumint mediumtextncharnvarcharnumericsetsmallinttexttime timestamptinyblobtinyinttinytextuuid varbinary)varcharyearc0eZdZddZddZ ddZy)MySQLExecutionContextcd|jrtt|jjrz|j j sctj|j tt|jjDcgc]}|jdfc}g|_ yyyycc}wN) isdeleterrMcompiledeffective_returningrA description_cursor FullyBufferedCursorFetchStrategy_result_columnskeynamecursor_fetch_strategy)selfentrys d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/base.py post_execzMySQLExecutionContext.post_execs MM[$--0DDKK++88KK&*'&)/ !-    &,E sB- c|jjr/|jj|jjSt r)dialectsupports_server_side_cursors_dbapi_connectionrA _sscursorNotImplementedErrorrs rcreate_server_side_cursorz/MySQLExecutionContext.create_server_side_cursors@ << 4 4))00 && &' 'c^|jd|jj|z|S)Nzselect nextval(%s))_execute_scalaridentifier_preparerformat_sequence)rseqtype_s r fire_sequencez#MySQLExecutionContext.fire_sequence%s9##$**::3?@    rNreturnNone)rr\)rSequence_SchemaItemrzsqltypes.Integerrr)__name__ __module__ __qualname__rrrrrrrs)4(  &  /?    rrceZdZUded<dZ ej jjZejddid.dZ d/dZ d0dZ d1d Z d2d Zd3d Z d4d Z d4d Z d4dZ d5dZ d6dZ d4dZedZdZd7dZ d8dZ d9dZ d: d;dZddZd?dZ d@fd Z! dA dBdZ" dCdZ# dCdZ$dDd Z%dEd!Z& dFd"Z' dGd#Z( dHd$Z) dId%Z* dJd&Z+ d4d'Z, d4d(Z- dKd)Z. dLd*Z/ d4d+Z0 d4d,Z1 d4d-Z2xZ3S)M MySQLCompiler MySQLDialectrT milliseconds millisecondcZ|jr|jdd}|jryy)zlCalled when a ``SELECT`` statement has no froms, and no ``FROM`` clause is to be appended. rkz FROM DUAL)stack_where_criteria)rstmts r default_fromzMySQLCompiler.default_from9s, ::::b>,/D###rc *d|j|zS)Nzrand%s)function_argspecrfnkws rvisit_random_funczMySQLCompiler.visit_random_funcEs$//333rc Zdjfd|jD}|dS)N, c3DK|]}|jfiywr_compiler_dispatch.0elemrrs r z2MySQLCompiler.visit_rollup_func..I) 48 #D # #D /B /  z WITH ROLLUPjoinclauses)rrrclauses` ` rvisit_rollup_funczMySQLCompiler.visit_rollup_funcHs1 <>JJ  &&rc Jfd|jD\}}d|d|dS)Nc3DK|]}|jfiywrrrs rrz=MySQLCompiler.visit_aggregate_strings_func..Qrrz group_concat(z SEPARATOR ))r)rrrexpr delimeters` ` rvisit_aggregate_strings_funcz*MySQLCompiler.visit_aggregate_strings_funcNs1 <>JJ itfK {!<d|jj|zS)Nz nextval(%s))preparerr)rsequencers rvisit_sequencezMySQLCompiler.visit_sequenceVst}}<d j@jjd d jCd |Drd dd jC| Sdd jC| Scc}wcc}wcc}wcc} }wcc}w)Nnewnew_1c3@K|]}|jvs|ywrkey)rcolon_duplicate_updates rrz>MySQLCompiler.visit_on_duplicate_key_update..sMscgg9L.LsMs)rF) use_schemact|tjr1|jjr|j jSt|tj r|jjurkr5djj|j}t|Sdjj|jd}t|Sy)N.zVALUES(r) isinstancerF BindParameterr_isnull_with_binary_element_type ColumnClausetableinserted_aliasrquotenamer=)elementrcolumn_literal_clause_on_dup_alias_namecolumn on_duplicaterequires_mysql8_aliasrs rreplacez.replaces#7H,B,BC#LL00&@@MM"7H,A,AB#MM\-H-HH0#5"6a#'==#6#6w||#D"E!G2 ..CDD#*$--*=*=gll*K)LA N2 ..CDD $rz = z?Additional column names not matching any column keys in table 'z': rc3&K|] }d|z yw)'%s'Nr)rcs rrz>MySQLCompiler.visit_on_duplicate_key_update..s@avz@szAS z ON DUPLICATE KEY UPDATE zON DUPLICATE KEY UPDATE )rrurrrzOptional[ExternallyTraversible])"current_executable_parameter_orderingrDexpectrI DMLColumnRolerrr'rlistselectr$_requires_alias_for_on_duplicate_keyrlowerupdateitems expect_as_key _is_literalrFrrr self_grouprKreplacement_traverserrappendr@warn statementr)rr"rr8rparameter_ordering ordered_keysr'colsrvalueval value_textr$ name_text non_matchingr r!rr#s`` @@@@rvisit_on_duplicate_key_updatez+MySQLCompiler.visit_on_duplicate_key_updates!% 7 7   + +(;;"  !4!4c:" "12L.)//+++!!#&&OO--Kql1JK LD  ))*D ) 0 0D 8! LL = =  !##))+u4%,"%*"+11779 U  # #E$7$7 =u D  NdM( @F%fjj1C$$S),,T3fkkJ!\\#..*:u\M $2$:=$4$$433CWE!\\#..*:u\M  ++FKK8I NN :> ?Q( @T./$2GQ1552GG  IINN((--YY@<@@   !()*++/99W+=*>@  .dii.@-AB Bu" L  `3Hs#+L=)8M;MM+/M 'Mc Vddjfd|jDzS)Nz concat(%s)rc3DK|]}j|fiywrrrs rrzFMySQLCompiler.visit_concat_op_expression_clauselist..s!N4ldll4.2.Nrr)r clauselistrrs` `r%visit_concat_op_expression_clauselistz3MySQLCompiler.visit_concat_op_expression_clauselists* IIN:;M;MN N  rc d|j|jfi|d|j|jfi|dS)Nzconcat(rrrrrrs rvisit_concat_op_binaryz$MySQLCompiler.visit_concat_op_binarys< DLL + + DLL , ,  r))FFF)TFF)FTF)FFT)FTT)zIN BOOLEAN MODEzIN NATURAL LANGUAGE MODEzWITH QUERY EXPANSIONc >|j||jfi|Sr)visit_match_op_binaryr)rrrs rvisit_mysql_matchzMySQLCompiler.visit_mysql_match4s")t))'73C3CJrJJrc  |j}|jdd}|jdd}|jdd}|||f}||jvr7d|zd|zd|zf} d j| } t j d | z|j |jfi|} |j |jfi|} t|r*t|j|} d j| g| } d | d | dS)zp Note that `mysql_boolean_mode` is enabled by default because of backward compatibility mysql_boolean_modeTmysql_natural_languageFmysql_query_expansionzin_boolean_mode=%szin_natural_language_mode=%szwith_query_expansion=%srzInvalid MySQL match flags: %srzMATCH (z ) AGAINST (r) modifiersget_match_valid_flag_combinationsrr< CompileErrorrrranyr_match_flag_expressions)rrwrrrQ boolean_modenatural_languagequery_expansionflag_combinationflags flags_str match_clauseagainst_clauseflag_expressionss rrKz#MySQLCompiler.visit_match_op_binary7s$$  }}%94@ $==)A5I#--(?G(*:OL 4#F#F F$|3-0@@)O;E  %(I""#BY#NO O#t||FKK626 %fll9b9  ',,    !XX~&I8H&IJN,8.IIrc|Srr)rrrs rget_from_hint_textz MySQLCompiler.get_from_hint_text_s  rc |%|jj|j}t|tj r|j ||jfi|St|tjrt|ddryyt|tjryt|tjtjtjtjfr%|jjj!|St|tj"rPt|t$t&fs:t)j*|}|jjj!|St|tj,ryt|tj.ryt|tj0r5|jjj!|j3dd St|tj4r;|jj6r%|jjj!|Sy) NunsignedFzUNSIGNED INTEGERzSIGNED INTEGERr$rOrr/r%)r dialect_implrrrJ TypeDecoratorvisit_typeclauseimplrgetattrr5r%DateTimeDateTimetype_compiler_instancerrrrr#_adapt_string_for_cast_Binaryrr/r$Float_support_float_cast)r typeclauserradapteds rrfzMySQLCompiler.visit_typeclauseds =OO00>E eX33 4(4((UZZF2F F x// 0uj%0)' x11 2    !!    <<66>>uE E x / D#;9 11%8G<<66>>wG G x// 0 x}} - x// 0<<66>>uEMM9  uhnn - 00<<66>>uE Erc x|j|j}|ztjd|jj j|jj z|j|jjfi|Sd|j|jfi|d|dS)NzMDatatype %s does not support CAST on MySQL/MariaDb; the CAST will be skipped.zCAST(z AS r) rrqr@r7rrlrrr4)rrrrs r visit_castzMySQLCompiler.visit_casts T__- = II,,,55==OO((  4<< 6 6 8?B? ? $04<< #Br#BEJJrcxt|||}|jjr|j dd}|S)N\z\\)superrender_literal_valuer_backslash_escapesr$)rr<r __class__s rrxz"MySQLCompiler.render_literal_values8,UE: << * *MM$/E rc y)Ntruerrrrs r visit_truezMySQLCompiler.visit_truerc y)Nfalserr}s r visit_falsezMySQLCompiler.visit_falsesrc t|jtr4tjdd|jj dzSt ||fi|S)zAdd special MySQL keywords in place of DISTINCT. .. deprecated:: 1.4 This usage is deprecated. :meth:`_expression.Select.prefix_with` should be used for special keywords at the start of a SELECT. zSending string values for 'distinct' is deprecated in the MySQL dialect and will be removed in a future release. Please use :meth:`.Select.prefix_with` for special keywords at the start of a SELECT statementz1.4)versionr)r _distinctstrr@warn_deprecatedupperrwget_select_precolumns)rr-rrzs rrz#MySQLCompiler.get_select_precolumnss^ f&& ,  5  ##))+c1 1w,V:r::rc |r1|jj|j|jf|jrd}n|j rd}nd}dj |j|jfd|d|||j|jfd|d|d|j|jfd|i|fS) Nz FULL OUTER JOIN z LEFT OUTER JOIN z INNER JOIN rT)asfrom from_linter ON r) edgesaddrrfullisouterrronclause)rrrrkwargs join_types r visit_joinzMySQLCompiler.visit_joins     ! !499djj"9 : 99+I \\+I&Iww II&* GM JJ'+HN T]]N NvN   rc |jJ|jjrd}nd}|jjrjjrtt j }|jjD]&}|jtj|(|ddjfd|Dzz }|jjr|dz }|jjr|dz }|S)Nz LOCK IN SHARE MODEz FOR UPDATEz OF rc3JK|]}j|fdddyw)TF)ashintrNrD)rrrrs rrz2MySQLCompiler.for_update_clause..s0& UH4EHRH&s #z NOWAITz SKIP LOCKED) _for_update_argreadofrsupports_for_update_ofr@ OrderedSetr0sql_utilsurface_selectables_onlyrnowait skip_locked)rr-rtmptablesr's` ` rfor_update_clausezMySQLCompiler.for_update_clauses%%111  ! ! & &'CC  ! ! $ $)L)L>Boo>OF++.. D h??BC D 6DII&#& C  ! ! ( ( 9 C  ! ! - - > !C rc |j|j}}||y|E|d|j|fi|ddSd|j|fi|d|j|fi|S|Jd|j|fi|S)Nrz LIMIT r18446744073709551615) _limit_clause_offset_clauser)rr-r limit_clause offset_clauses rrzMySQLCompiler.limit_clauses   ! !$  M$9  &#!DLL5"5* $!DLL5"5 DLL44  + ++%1T\\,%E"%EG Grc|jjd|jjzd}|dt |SyNz%s_limitzLIMIT rrRrrr)r update_stmtlimits rupdate_limit_clausez!MySQLCompiler.update_limit_clause,C""&&zDLL4E4E'EtL  CJ<( (rc|jjd|jjzd}|dt |Syrr)r delete_stmtrs rdelete_limit_clausez!MySQLCompiler.delete_limit_clause3rrc `dd<djfd|gt|zDS)NTrrc3DK|]}|jfiywrr)rtrrs rrz5MySQLCompiler.update_tables_clause..Bs+  !A  , , r)rr,)rr from_table extra_fromsrs` `rupdate_tables_clausez"MySQLCompiler.update_tables_clause:s88 yy  \D$55   rc yrr)rrrr from_hintsrs rupdate_from_clausez MySQLCompiler.update_from_clauseGsrc <d}|rd}|j|fdd|d|S)z=If we have extra froms make sure we render any alias as hint.FT)riscrudrr)rrrrrrs rdelete_table_clausez!MySQLCompiler.delete_table_clauseQs= F,z,,  d6 =?  rc Xdd<ddjfd|g|zDzS)z4Render the DELETE .. USING clause specific to MySQL.TrzUSING rc3HK|]}|jfdiyw) fromhintsNr)rrrrrs rrz9MySQLCompiler.delete_extra_from_clause..js0$  !A  B Br B$ s")r)rrrrrrs` ``rdelete_extra_from_clausez&MySQLCompiler.delete_extra_from_clause`s:8 $))$  \K/$    rc ddjdt|Ddjdt|DdzS)NzASELECT %(outer)s FROM (SELECT %(inner)s) as _empty_set WHERE 1!=1rc3,K|] \}}d|zyw)z 1 AS _in_%sNrridxrs rrz5MySQLCompiler.visit_empty_set_expr..vs!#"U"C'#c3,K|] \}}d|zyw)z_in_%sNrrs rrz5MySQLCompiler.visit_empty_set_expr..zs#'1sEHsN#r)innerouter)r enumerate)r element_typesrs rvisit_empty_set_exprz"MySQLCompiler.visit_empty_set_exprosV '#&/ &>##5>}5M#   rc xd|j|jd|j|jdS)NzNOT ( <=> rrHrs rvisit_is_distinct_from_binaryz+MySQLCompiler.visit_is_distinct_from_binarys. LL % LL &  rc t|j|jd|j|jS)NrrHrs r!visit_is_not_distinct_from_binaryz/MySQLCompiler.visit_is_not_distinct_from_binarys. LL % LL &  rc rd|j|tjd|j|fi|dS)Nz CONCAT('(?', z, ')', r)rxrJ STRINGTYPEr)rr[patternrs r_mariadb_regexp_flagsz#MySQLCompiler._mariadb_regexp_flagss7  % %eX-@-@ A DLL 'B '  rc |jJ|jd}||j||fi|S|jjr=|j|j fi|||j ||jSd|j|j fi|d|j|jfi|d|j|tjd}|dk(rd|zS|S)Nr[z REGEXP_LIKE(rr NOT REGEXP zNOT %s) rQ_generate_generic_binaryr is_mariadbrrrrrxrJr)r op_stringrwrrr[rs r _regexp_matchzMySQLCompiler._regexp_matchs+++  ) =0400IbI I \\ $ $ V[[/B/**5&,,? % V[[/B/ V\\0R0))%1D1DED N*$& rc ,|jd||fi|S)Nz REGEXP rrs rvisit_regexp_match_op_binaryz*MySQLCompiler.visit_regexp_match_op_binarys "t!!*fhE"EErc ,|jd||fi|S)Nrrrs r visit_not_regexp_match_op_binaryz.MySQLCompiler.visit_not_regexp_match_op_binarys "t!!.&(IbIIrc |jJ|jd}|?d|j|jfi|d|j|jfi|dS|jj rvd|j|jfi|d|j ||jjdd|j|jjdfi|dSd|j|jfi|d|j|jfi|d|j|tjdS)Nr[zREGEXP_REPLACE(rrrr) rQrrrrrrrrxrJr)rrwrrr[s rvisit_regexp_replace_op_binaryz,MySQLCompiler.visit_regexp_replace_op_binarys)+++  ) = V[[/B/ V\\0R0 \\ $ $ V[[/B/**5&,,2F2Fq2IJ V\\11!4;; % V[[/B/ V\\0R0))%1D1DE r)rr)rrqrrrr)rz rollup[Any]rrrr)rrprrrr)rzsa_schema.Sequencerrrr)rrsrrrr)rwelements.BinaryExpression[Any]rrrrrr)r"rXrrrr)rEzelements.ClauseListrrrrrr)rexpression.matchrrrr)rwrrrrrrr)rzselectable.FromClauser Optional[str]rrr)rqzelements.TypeClauserzOptional[TypeEngine[Any]]rrrr)rzelements.Cast[Any]rrrr)r<rrzTypeEngine[Any]rr)rzelements.True_rrrr)rzelements.False_rrrr)r-zselectable.Select[Any]rrrr)FN) rzselectable.JoinrboolrzOptional[compiler.FromLinter]rrrr)r-zselectable.GenerativeSelectrrrr)rrnrr)rrmrr) rrnrrlrList[selectable.FromClause]rrrr) rrnrrlrrrrrrrr) rrmrrlrrrrrr) rrmrrlrrrrrrrr)rzList[TypeEngine[Any]]rrrr)r[rrzelements.ColumnElement[Any]rrrr) rrrwrrrrrrr)4rrr__annotations__'render_table_with_column_in_update_fromrErM extract_mapcopyr0rrrrrrrrr rArFrI frozensetrSrVrLrKrarfrtrxr~rrrrrrrrrrrrrrrrrrr __classcell__rzs@rrr1s .2+0&&22779K 67 4' =#=+.= =GI@4I@@CI@KNI@ I@VM4M@CMKNM M M4M@CMKNM M aC-aC58aC aCF - 9< DG   4 @C KN  &/  &" K&J&&J25&J=@&J &JP*2? ,0.'.). .  .` K"+: ;,;47; ;259    3     >19< 6(H1(H9<(H (HT    %  1     %1          %  1         %  1          2 :=  " 4 @C KN   4 @C KN    #> FI  /    8F4F@CFKNF F J4J@CJKNJ J 4@CKN rrceZdZUded< d dZddZddZ dfd ZddZ ddZ dd Z dd Z dd Z dd Z xZS)MySQLDDLCompilerrrc H|jjdur/|j#|jtj urd|_|jj||jjj|j|g}|j*|j|j|jt|jj|jtj }|j s|jdn|j r|r|jd|j"}|B|j$j'|tj(}|jd|z|j*||j*j,ur|j.$t|j.t0j2rb|jj4r:t|j6t0j8r|j6j:r|jdn|j=|}||jj>rtAjBd|svtAjDd|t@jFsQtAjBd |t@jFs,tAjBd |r|jd |d n|jd |zdjI|S)zBuilds column DDL.T)rzNOT NULLNULLzCOMMENT AUTO_INCREMENTz ^\s*[\'\"\(]z ON +UPDATEz'\bnow\(\d+\)|\bcurrent_timestamp\(\d+\)z.*\W.*z DEFAULT (rzDEFAULT r)%rrcomputed_user_defined_nullablerNNULL_UNSPECIFIEDnullabler format_columnrlrrr6r_unwrapped_dialect_implrJr5comment sql_compilerrxrr_autoincrement_columnserver_default sa_schemaIdentitysupports_sequencesrBroptionalget_column_default_string_support_default_functionrematchsearchIr)rr!rcolspec is_timestamprliteralrBs rget_column_specificationz)MySQLDDLCompiler.get_column_specificationsZ LL # #t ++--1M1MM"FO MM ' ' / LL / / 7 7 V 8   ?? & NN4<<8 9! KK / / =     NN: &__ NN6 "..  ''<<*G NN:/ 0 LL $&,,<<<%%-f33Y5G5GH //v~~y/A/AB// NN+ ,44VIImWbddCHHB G4NNYwiq#9:NN:#78xx  rcZg}|jjDcic]a\}}|jd|jjzr4|t |jjdzdj |c}}}|j|j|d<gd}t|j|}t|j|}tjgd|D]} || } | tjvr.|jj!| t#j$} | dvr| j'dd } d } | d vrd } |j)| j+| | ftjgd |D]}} || } | tjvr.|jj!| t#j$} | j'dd } d } |j)| j+| | fd j+|Scc}}w) z9Build table-level CREATE options like ENGINE and COLLATE.z%s_rNCOMMENT) PARTITION_BY PARTITIONS SUBPARTITIONSSUBPARTITION_BY))DEFAULT_CHARSETCOLLATE)DEFAULT_CHARACTER_SETr)CHARSETr) CHARACTER_SETr)DATA_DIRECTORYINDEX_DIRECTORYrrrDEFAULT_COLLATE_r=) TABLESPACEzDEFAULT CHARACTER SETz CHARACTER SETr))rr)rr)rr)rr)rr)rr)rr1 startswithrrlenrrr difference intersectionrVsort _reflection_options_of_type_stringrrxrJrr$r6r) rr table_optskvoptspartition_optionsnonpart_options part_optionsoptargjoiners rpost_create_tablez"MySQLDDLCompiler.post_create_table"s+  **, 1||EDLL$5$556 c$,,##$q(* + 1 1 3Q 6  == $#mmDO d)../@A4y--.?@ ##   " 7Cs)Ck999''<<*kk#s+F    fkk3*5 6E" 7H##     7Cs)Ck999''<<*++c3'CF   fkk3*5 6) 7,xx ##[ sA&H'c |j}|j||j}|j|j}|j Dcgc]}|j jt|tjs`t|tjr,|jtjtjfvst|t j"rtj$|n|dd}}|j'|}d} |j(r| dz } |j*j-d|j.j0zd} | r| | dzz } | dz } |j2r| d z } | |d |dz } |j4|j.j0d Ztt6r/d j9fd t;|j |D} n,d j9fd|D} nd j9|} | d| zz } |j4dd} | | d| z } |j4dd} | | d|j=| zz } | Scc}w)NFT) include_table literal_bindszCREATE zUNIQUE %s_prefixrINDEX zIF NOT EXISTS rlengthrc3K|]<\}}|jvrd||jfzn|vr d||fznd|z>yw)%s(%d)z%sN)r)rrrr7s rrz6MySQLDDLCompiler.visit_create_index..sh ("T88v-!D&*:#;; $v~%fTl';;!%  (sAAc3,K|] }d|fz yw)r9Nr)rrr7s rrz6MySQLDDLCompiler.visit_create_index..s(14HV},(sz(%s)mysql with_parserz WITH PARSER using USING %s)r_verify_index_tabler format_tabler expressionsrrrrFBinaryExpressionUnaryExpressionmodifierrHdesc_opasc_oprGFunctionElementGrouping_prepared_index_nameuniquerrRrr if_not_existsdialect_optionsdictrzipr)rcreaterindexrrrcolumnsrr index_prefix columns_strparserr=r7s @rvisit_create_indexz#MySQLDDLCompiler.visit_create_indexvsm   '==%%ekk2())% $#    % %#4)B)BC&tX-E-EF $ $-$5$5y7G7G#H!I&dI,E,EF%%d+#" &   *((/ << I D||'' dll6G6G(GN  L3& &D     $ $D tU++&&t||'8'89(C  &$'#ii (&)):):G%D (  #ii(8?( ))G,K $$&&w/ >   1 1D%%g.w7   K8>>%#89 9D Q sB4I0c t||}|jdd}|r!|d|jj |zz }|S)Nr;r=r>)rwvisit_primary_key_constraintrLrr)r constraintrrr=rzs rrWz-MySQLDDLCompiler.visit_primary_key_constraintsOw3J?**73G<  K4==#6#6u#=> >D rc |j}d}|jr|dz }||j|dd|jj |j zS)Nz DROP INDEX z IF EXISTS F)include_schemar)r if_existsrIrr@r)rdroprrPrs rvisit_drop_indexz!MySQLDDLCompiler.visit_drop_indexs\  >> L D  % %eE % B MM & &u{{ 3   rc n|j}t|tjrd}|jj |}nt|tj rd}d}nt|tjrd}|jj |}nnt|tjr7|jjrd}nd}|jj |}nd}|jj |}d|jj|jd||S) Nz FOREIGN KEY z PRIMARY KEY rr6z CONSTRAINT zCHECK ALTER TABLE z DROP ) rrrForeignKeyConstraintrformat_constraintPrimaryKeyConstraintUniqueConstraintCheckConstraintrrr@r)rr\rrXqualconsts rvisit_drop_constraintz&MySQLDDLCompiler.visit_drop_constraints\\ j)"@"@ A!DMM33J?E  I$B$B C!DE  I$>$> ?DMM33J?E  I$=$= >||&&$MM33J?EDMM33J?E MM & &z'7'7 8    rcF|jtjdy)NzjMySQL ignores the 'MATCH' keyword while at the same time causes ON UPDATE/ON DELETE clauses to be ignored.r)rr<rT)rrXs rdefine_constraint_matchz(MySQLDDLCompiler.define_constraint_matchs.    '""D rc d|jj|jd|jj |jj t jS)Nr_z COMMENT )rr@rrrxrrJrrrOrs rvisit_set_table_commentz(MySQLDDLCompiler.visit_set_table_comment sN MM & &v~~ 6    2 2&&(9   rc Rd|jj|jzS)NzALTER TABLE %s COMMENT '')rr@r)rr\rs rvisit_drop_table_commentz)MySQLDDLCompiler.visit_drop_table_comment s'+ MM & &t|| 4  rc d|jj|jjd|jj |jd|j |jS)Nr_z CHANGE r)rr@rrrrrks rvisit_set_column_commentz)MySQLDDLCompiler.visit_set_column_comment sR MM & &v~~';'; < MM ' ' 7  ) )&.. 9  r)r!zsa_schema.Column[Any]rrrr)rzsa_schema.Tablerr)rOzddl.CreateIndexrrrr)rXzsa_schema.PrimaryKeyConstraintrrrr)r\z ddl.DropIndexrrrr)r\zddl.DropConstraintrrrr)rXzsa_schema.ForeignKeyConstraintrr)rOzddl.SetTableCommentrrrr)r\zddl.DropTableCommentrrrr)rOzddl.SetColumnCommentrrrr)rrrrrr1rUrWr]rgrirlrnrprrs@rrrs G!+G!36G! G!RR$hN`8@C    & .1  88  ) 14   ( 03   * 25  rrcxeZdZd)dZ d*dZd+dZd,dZd-dZd.dZd/dZ d0dZ d1d Z d2d Z d3d Z d4d Zd5d Zd6dZd7dZd8dZd9dZd:dZd;dZddZd?dZd@dZdAdZdBdZdCdZdDdZdEdZdFdZ dGdZ!dHfd Z"dGd!Z#dId"Z$dJd#Z%dKd$Z& dLd%Z'dHd&Z(dMd'Z)dNd(Z*xZ+S)OMySQLTypeCompilercp|j|s|S|jr|dz }|jr|dz }|S)zAExtend a numeric-type declaration with MySQL specific extensions.z UNSIGNEDz ZEROFILL) _mysql_typerczerofill)rrspecs r_extend_numericz!MySQLTypeCompiler._extend_numeric s>&K >> K D >> K D rcndfd }|dr d|dz}n|drd}n |drd}nd}|d rd jz}n |d rd }nd}|d r%djd||fDcgc]}|| c}Sdj|||fDcgc]}|| c}Scc}wcc}w)zExtend a string-type declaration with standard SQL CHARACTER SET / COLLATE annotations and MySQL specific extensions. c<t|j|Sr)rhrR)rdefaultsrs rattrz.MySQLTypeCompiler._extend_string..attr0 s5$ T(:; ;rcharsetzCHARACTER SET %sasciiASCIIunicodeUNICODEN collationz COLLATE %srwrOnationalrNATIONAL)rrrr)rr)rrrzrvr{r|rr's `` r_extend_stringz MySQLTypeCompiler._extend_string( s <  ?(4 ?:G ']G )_GG  $u6I (^ II  88'y9KqQ]K xxw 2 D1amQ D  L Es5B-=B-B2"B2c.t|ttfSr)rr r)rrs rrtzMySQLTypeCompiler._mysql_typeM s%+|!<==rc |j|j|dS|j!|j|dd|jizS|j|d|j|jdzS)Nr/zNUMERIC(%(precision)s)rz!NUMERIC(%(precision)s, %(scale)s)rrrrwrrrrs r visit_NUMERICzMySQLTypeCompiler.visit_NUMERICP ?? "''y9 9 [[ ''(K+II  ''3 %%++FG rc |j|j|dS|j!|j|dd|jizS|j|d|j|jdzS)Nr%zDECIMAL(%(precision)s)rz!DECIMAL(%(precision)s, %(scale)s)rrrs r visit_DECIMALzMySQLTypeCompiler.visit_DECIMAL_ rrc |j8|j,|j|d|j|jdzS|j|dS)Nz DOUBLE(%(precision)s, %(scale)s)rr&rrrwrs r visit_DOUBLEzMySQLTypeCompiler.visit_DOUBLEn sY ?? &5;;+B''2 %%++FG  ''x8 8rc |j8|j,|j|d|j|jdzS|j|dS)NzREAL(%(precision)s, %(scale)s)rr1rrs r visit_REALzMySQLTypeCompiler.visit_REALx sY ?? &5;;+B''0 %%++FG  ''v6 6rc *|j|rE|j9|j-|j|d|jd|jdS|j |j|d|jdS|j|dS)NzFLOAT(rrr')rtrrrwrs r visit_FLOATzMySQLTypeCompiler.visit_FLOAT s   U # '+''%//5;;G __ (''eoo7 ''w7 7rc |j|r-|j!|j|dd|jizS|j|dS)NzINTEGER(%(display_width)s) display_widthr(rtrrwrs r visit_INTEGERzMySQLTypeCompiler.visit_INTEGER s\   E "u':':'F'',"E$7$789  ''y9 9rc |j|r-|j!|j|dd|jizS|j|dS)NzBIGINT(%(display_width)s)rr!rrs r visit_BIGINTzMySQLTypeCompiler.visit_BIGINT s\   E "u':':'F''+"E$7$789  ''x8 8rc |j|r-|j!|j|dd|jizS|j|dS)NzMEDIUMINT(%(display_width)s)rr,rrs rvisit_MEDIUMINTz!MySQLTypeCompiler.visit_MEDIUMINT s\   E "u':':'F''."E$7$789  ''{; ;rc |j|r+|j|j|d|jzS|j|dS)Nz TINYINT(%s)r7rrs r visit_TINYINTzMySQLTypeCompiler.visit_TINYINT sS   E "u':':'F''}u':':: ''y9 9rc |j|r-|j!|j|dd|jizS|j|dS)NzSMALLINT(%(display_width)s)rr2rrs rvisit_SMALLINTz MySQLTypeCompiler.visit_SMALLINT s\   E "u':':'F''-"E$7$789  ''z: :rc :|jd|jzSy)NzBIT(%s)r"r7rs r visit_BITzMySQLTypeCompiler.visit_BIT s << #u||+ +rc <t|ddrd|jzSy)Nfspz DATETIME(%d)r$rhrrs rvisit_DATETIMEz MySQLTypeCompiler.visit_DATETIME s 5% &!EII- -rc y)NrRrrs r visit_DATEzMySQLTypeCompiler.visit_DATE rrc <t|ddrd|jzSy)NrzTIME(%d)r4rrs r visit_TIMEzMySQLTypeCompiler.visit_TIME s 5% & ) )rc <t|ddrd|jzSy)Nrz TIMESTAMP(%d)r5rrs rvisit_TIMESTAMPz!MySQLTypeCompiler.visit_TIMESTAMP s 5% &"UYY. .rc :|jyd|jzS)Nr:zYEAR(%s))rrs r visit_YEARzMySQLTypeCompiler.visit_YEAR s"    & 3 33 3rc |j |j|id|jzS|j|idS)NzTEXT(%d)r3r7rrs r visit_TEXTzMySQLTypeCompiler.visit_TEXT s? << #&&ub*u||2KL L&&ub&9 9rc (|j|idS)Nr8rrs rvisit_TINYTEXTz MySQLTypeCompiler.visit_TINYTEXT ""5"j99rc (|j|idS)Nr-rrs rvisit_MEDIUMTEXTz"MySQLTypeCompiler.visit_MEDIUMTEXT s""5"l;;rc (|j|idS)Nr*rrs rvisit_LONGTEXTz MySQLTypeCompiler.visit_LONGTEXT rrc |j |j|id|jzStjd|jj z)Nz VARCHAR(%d)z'VARCHAR requires a length on dialect %sr7rr<rTrrrs r visit_VARCHARzMySQLTypeCompiler.visit_VARCHAR sO << #&&ub-%,,2NO O""9DLL ?"" 24,)?@  rc <|jd||jSr)rrrs r visit_ENUMzMySQLTypeCompiler.visit_ENUMI s,,VUEKKHHrc <|jd||jS)Nr)rvaluesrs r visit_SETzMySQLTypeCompiler.visit_SETL s,,UE5<<HHrc y)NBOOLrrs r visit_BOOLEANzMySQLTypeCompiler.visit_BOOLEANO rr)rrrvrrr)rr rzDict[str, Any]rvrrr)rrrr)rr/rrrr)rr%rrrr)rr&rrrr)rr1rrrr)rr'rrrr)rr(rrrr)rr!rrrr)rr,rrrr)rr7rrrr)rr2rrrr)rr"rrrr)rr$rrrr)rrRrrrr)rr4rrrr)rr5rrrr)rr:rrrr)rr3rrrr)rr8rrrr)rr-rrrr)rr*rrrr)rr9rrrr)rr#rrrr)rr0rrrr)rr.rrrr)rz UUID[Any]rrrr)rrUrrrr)rrrrrr)rrSrrrr)rrrrrr)rr6rrrr)rr+rrrr)rr)rrrr)rrrr rz Sequence[str]rr)rrrrrr)rzsqltypes.Booleanrrrr),rrrrwrrtrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrs@rrrrr s #  # ,:# BE# # J>  978 :9<:;    4 : :<::  J.&M      +  @M    IIrrrc:eZdZeZ d dfd ZddZxZS)MySQLIdentifierPreparerc 8|sd}nd}t||||y)N`") initial_quote escape_quote)rw__init__)rrserver_ansiquotesrrrzs rrz MySQLIdentifierPreparer.__init__V s& !EE EJrcbt|Dcgc]}||j|c}Scc}w)z4Unilaterally identifier-quote any number of strings.)tuplequote_identifier)ridsis r_quote_free_identifiersz/MySQLIdentifierPreparer._quote_free_identifiersc s,M1q}d++A.MNNMs,,)F)rzdefault.DefaultDialectrrrr)rrrzTuple[str, ...])rrrrreserved_wordsrrrrs@rrrS s8)N #( K' K  K KOrrceZdZeZy)MariaDBIdentifierPreparerN)rrrrrrrrrri s+Nrrc neZdZUdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZded<ej0ZdZdZdZdZdZdZd Z e!Z!dZ"e#Z$e%Z&e'Z(e)Z)e*Z+d ed <dZ,ded <d Z-dZ.dZ/ded<ded<e0jbdd ife2jfdd ife2jhdd ife0jjdd ife0jld d d d dfgZ7 dP dQdZ8 dRdZ9 dSdZ: dTdZ;edWdZ? dXdZ@dYdZAdYdZB dZ d[d ZC dZ d[d!ZDd\d"ZE d]d#ZF d^ d_d$ZG d^ d`d%ZH d^ dad&ZI dbd'ZJdcd(ZKeLj d^ ddd)ZNeLj d^ ded*ZOdfd+ZPeLj d^ dgd,ZQdhd-ZRdid.ZSeTdjd/ZUeTdjd0ZVeTdjd1ZWeTdjd2ZXeTdjd3ZYeLjdkd4ZZeLj d^ dgd5Z[eLj d^ dgd6Z\eLj d^ dld7Z]eLj d^ dmd8Z^eLj d^ dnd9Z_eLj d^ dod:Z` dpd;ZaeLj d^ dqd<ZbeLj d^ drd=ZceLj d^ dsd>ZdeLj d^ dtd?ZeeLj d^ dud@Zf d^ dvdAZgehjdwdBZjeLj d^ dvdCZk dxdDZldcdEZmdydFZndzdGZodhdHZpdhdIZqer d{dJZser d| d}dKZs d| d~dLZser ddMZter d| ddNZt d| ddOZty )rzMDetails of the MySQL dialect. Not used directly in application code. r;TF@ruse_insertmanyvaluesformatztype[MySQLIdentifierPreparer]rrNTuple[int, ...]server_version_inforr*rr=)r=r7prefixr<c |jddtjj|fi|||_||_|j |dy)Nuse_ansiquotesr)poprBDefaultDialectr_json_serializer_json_deserializer _set_mariadb)rjson_serializerjson_deserializerrrs rrzMySQLDialect.__init__ sL  #T*''77 /"3 *b)rcy)N) SERIALIZABLEzREAD UNCOMMITTEDzREAD COMMITTEDzREPEATABLE READr)r dbapi_conns rget_isolation_level_valuesz'MySQLDialect.get_isolation_level_values s rc|j}|jd||jd|jy)Nz(SET SESSION TRANSACTION ISOLATION LEVEL COMMIT)rAexecuteclose)rdbapi_connectionlevelrAs rset_isolation_levelz MySQLDialect.set_isolation_level s;"((*A%IJx  rc|j}|jr!|jdk\r|jdn|jd|j }|t j dt|d}|jt|tr|j}|jjddS)N)zSELECT @@transaction_isolationzSELECT @@tx_isolationzDCould not retrieve transaction isolation level for MySQL connection.r-r)rA _is_mysqlrrfetchoner@r7rrrbytesdecoderr$)rrrArowr=s rget_isolation_levelz MySQLDialect.get_isolation_level s"((* >>d66*D NN; < NN2 3oo ; II &' '!f  c5 !**,Cyy{""3,,rcV|j}||}|j|\}}|j|i|} |j}|j d|j d}t ||jS#xYw#|jwxYw)N)dbapiz!SELECT VERSION() LIKE '%MariaDB%'r) import_dbapicreate_connect_argsconnectrArr#rr) clsurlr)rcargscparamsconnrAr=s r_is_mariadb_from_urlz!MySQLDialect._is_mariadb_from_url s  "E" 44S9ww11 [[]F NN> ?//#A&C9 JJL    JJLs4B5 BBBB(c|j}|j}|jd|jd}|j t |t r|j}|j|S)NzSELECT VERSION()r) connectionrArr#rrr$r%_parse_server_version)rr4 dbapi_conrAr=s r_get_server_version_infoz%MySQLDialect._get_server_version_info sj )) !!#)*oo"  c5 !**,C))#..rcg}d}tjd}|j|}|D]m}tjd|}|s|j drt |dd|_d}Ct|j d}|j|ot |} |jt| xr|| |s| |_| dkr td | |_ | S) NFz[.\-+]z"^(?:(\d+)(?:a|b|c)?|(MariaDB\w*))$Tr)rrr9zGthe MySQL/MariaDB dialect supports server version info 5.0.2 and above.) rcompilesplitrgroupr _mariadb_normalized_version_inforr6rrrr) rr=rrrtokenstoken parsed_tokendigitrs rr5z"MySQLDialect._parse_server_version$ s JJy ! &E885uL ##A&8=gbcl8K5! L..q12u% &$Gn  $3 46I 4GD 1  *%0  $7 ""rc 6|y|sB|jr6tjddjt t |d|rIt |jts!t|_|j||_ d|_ d|_ ||_y)NzMySQL version rz is not a MariaDB variant.T) rr<InvalidRequestErrorrmapr issubclassrrrdelete_returninginsert_returning)rrrs rrzMySQLDialect._set_mariadbJ s   doo))88C%89:=  dmm-FG 9 ,0==+>(%)D !$(D !$rcb|jtjdt|y)Nz XA BEGIN :xidxidrr?rrMrr4rLs rdo_begin_twophasezMySQLDialect.do_begin_twophased s388O4dsmDrc|jtjdt||jtjdt|y)N XA END :xidrKzXA PREPARE :xidrMrNs rdo_prepare_twophasez MySQLDialect.do_prepare_twophaseg s=388M2DSMB388$56 Frc|s/|jtjdt||jtjdt|y)NrQrKzXA ROLLBACK :xidrMrr4rL is_preparedrecovers rdo_rollback_twophasez!MySQLDialect.do_rollback_twophasek sB   sxx 6 F388$67#Grc|s|j|||jtjdt |y)NzXA COMMIT :xidrK)rRrr?rrMrTs rdo_commit_twophasezMySQLDialect.do_commit_twophasev s5  $ $Z 5388$45t}Erc||jd}|jDcgc] }|dd|dc}Scc}w)Nz XA RECOVERdatar gtrid_length)exec_driver_sqlmappings)rr4 resultsetr&s rdo_recover_twophasez MySQLDialect.do_recover_twophase sM..|< !))+  KC/ 0   s9cHt||jj|jj|jjfr|j |dvryt||jj|jj fr dt|vSy)N)iiiiiiiTz(0, '')F)rr)OperationalErrorProgrammingErrorInterfaceError_extract_error_code InternalErrorr)rrr4rAs r is_disconnectzMySQLDialect.is_disconnect s   ++ ++ ))  &&q).     ))4::+C+CD A& &rc\|jDcgc]}t||c}Scc}w)zMProxy result rows to smooth over MySQL-Python driver inconsistencies.)fetchall _DecodingRowrrpr|r&s r_compat_fetchallzMySQLDialect._compat_fetchall s% 79kkmDs S'*DDDs)c@|j}|r t||SyzNProxy a result row to smooth over MySQL-Python driver inconsistencies.N)r#rjrks r_compat_fetchonezMySQLDialect._compat_fetchone s" kkm W- -rc@|j}|r t||Syro)firstrjrks r _compat_firstzMySQLDialect._compat_first s" hhj W- -rctrr)r exceptions rrez MySQLDialect._extract_error_code s "##rc@|jdjS)NzSELECT DATABASE())r]scalarrr4s r_get_default_schema_namez%MySQLDialect._get_default_schema_name s))*=>EEGGrc |j|| |j}|Jdj|jj ||} |j d|ddi5}|j ducdddS#1swYyxYw#tj$r(}|j|jdvrYd}~yd}~wwxYw)Nrz DESCRIBE skip_user_error_eventsT)execution_options)ziiF) _ensure_has_table_connectiondefault_schema_namerrrr]r#r< DBAPIErrorreorig)rr4 table_namer>r full_namersrs r has_tablezMySQLDialect.has_table s ))*5 >--F!!!HH  $ $ < <    ++I;'#;T"B, 1{{}D0  1 1 1 ~~ ''/3EE # s<B(B: BB  B BC #CCC c |js|j|s |j}|jt j dt t|t|}|jduS)NzSELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='SEQUENCE' and TABLE_NAME=:name AND TABLE_SCHEMA=:schema_name)r schema_name) r_sequences_not_supportedrrr?rrMrrr)rr4 sequence_namer>rrAs r has_sequencezMySQLDialect.has_sequence sv&&  ) ) +--F## HH,  'K   ||~T))rctd)NzBSequences are supported only by the MariaDB series 10.3 or greaterrurs rrz%MySQLDialect._sequences_not_supported s! -  rc |js|j|s |j}|jt j dt |}|j||jDcgc]}|d c}Scc}w)NzjSELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='SEQUENCE' and TABLE_SCHEMA=:schema_name)rr|r) rrrrr?rrMrm_connection_charset)rr4r>rrAr&s rget_sequence_nameszMySQLDialect.get_sequence_names% s&&  ) ) +--F## HHL  V $  ,, 8 8-  F   s9 Bc|j||_tjj |||j ||j ||j||jr"|j||j|_ |jxr|jdk\|_ |jxr|jdk\|_|j xr|jdk\|_|jxr|jdk\|_|jxr|jdk\|_|jxr|jdk\|_|j)y)N)r) r;))rrr)rr)rrr )_detect_charsetrrBr  initialize_detect_sql_mode_detect_ansiquotes_detect_casing_server_ansiquotesrrrrrr"r_needs_correct_for_88718_96365rHrIr._warn_for_known_db_issuesrys rrzMySQLDialect.initialize< s_372F2F 3   ))$ ; j)  + J'  " "(,}}(?(?(5(D $ OO C 8 8G C  NN ?t774? #   DD$<$<$D + OO F 8 8J F  OO C 8 8G C  NN Et77:E 1 &&(rc|jr6|j}|J|dkDr |dkrtjd|dyyyy)Nrr9)rr9 zMariaDB aV before 10.2.9 has known issues regarding CHECK constraints, which impact handling of NULL values with SQLAlchemy's boolean datatype (MDEV-13596). An additional issue prevents proper migrations of columns with CHECK constraints (MDEV-11114). Please upgrade to MariaDB 10.2.9 or greater, or use the MariaDB 10.1 series, to avoid these issues.)rr>r@r7)r mdb_versions rrz&MySQLDialect._warn_for_known_db_issuesm sU ????K* **W$z)A 9D F*B$ rcp|jsy|jr|jdk\S|jdk\S)NF)rr)rrrrrs rrpz MySQLDialect._support_float_cast| 9'' __++z9 9++z9 9rcp|jsy|jr|jdk\S|jdk\S)NF)rr9r)rr rrs rrz&MySQLDialect._support_default_function rrc|jSrrrs r _is_mariadbzMySQLDialect._is_mariadb s rc|j Srrrs rr"zMySQLDialect._is_mysql s??""rc<|jxr|jdkDS)Nr)rr>rs r_is_mariadb_102zMySQLDialect._is_mariadb_102 s( OO 55 rc T|jd}|Dcgc]}|d c}Scc}w)Nz SHOW schemasr)r])rr4rrlr?s rget_schema_nameszMySQLDialect.get_schema_names s*  ' ' 7 !!!!!s %c ||}n |j}|j}|jd|jj |z}|j ||Dcgc]}|ddk(r|dc}Scc}w)z1Return a Unicode SHOW TABLES from a given schema.SHOW FULL TABLES FROM %srrz BASE TABLErrrr]rrrm)rr4r>rcurrent_schemar|rlr&s rget_table_nameszMySQLDialect.get_table_names s  "(N!55N**  ' ' &&&77G H ,,R,A 1v% F   s A7c | |j}|J|j}|jd|jj |z}|j ||Dcgc]}|ddvr|dc}Scc}w)Nrrr)VIEWz SYSTEM VIEWrr)rr4r>rr|rlr&s rget_view_nameszMySQLDialect.get_view_names s >--F!!!**  ' ' &&&77? @  ,,R,A 1v00 F   s!A7c |j|||fi|}|jr |jStjSr)_parsed_state_or_create table_optionsrCrr4rr>r parsed_states rget_table_optionszMySQLDialect.get_table_options sK4t33  F .0   % %-- -%335 5rc |j|||fi|}|jr |jStjSr)rrQrCrs r get_columnszMySQLDialect.get_columns sK4t33  F .0    '' '%--/ /rc |j|||fi|}|jD]&}|ddk(s |dDcgc]}|d }}|ddcStjScc}w)NrPRIMARYrQr)constrained_columnsr)rkeysrC pk_constraint) rr4rr>rrrsr;s rget_pk_constraintzMySQLDialect.get_pk_constraint s4t33  F .0  $$ CC6{i'&))n5!55/3TBB  C "//116s Ac |j|||fi|}d}g}|jD]}|dd} t|ddkDxr|ddxs|} | s||jj}||k(r|} |d} |d} i} dD]}|j |dd vs||| |<!|d | | | | | d }|j ||jr|j|||r|StjS) Nrrrlocalforeign)onupdateondeleteF)z NO ACTIONNr)rrreferred_schemareferred_tablereferred_columnsoptions) rfk_constraintsr!rrrRr6r#_correct_for_mysql_bugs_88718_96365rC foreign_keys)rr4rr>rrdefault_schemafkeysrvref_name ref_schema loc_names ref_namescon_kwr.fkey_ds rget_foreign_keyszMySQLDialect.get_foreign_keys sG4t33  F .0 57 // !DG}R(HT']+a/EDM"4EOJ!)%/%7%7%K%KN^+!'JW IYIF/ ,88C'/BB"&s)F3K , V '0#-"*$-! 5F LL 5 !8  . .  4 4UJ GuD#5#B#B#DDrc|jdvrd d}nd d}|jj}td}|D]=}||dxs|}||d}|dD]} |||j | ?|rqt j d|jD} t jtjjtjjtjjj| } |j| } t!t"} | D]V\}}}|| ||||fd <|| ||||fd <|| ||||f|j%<X|D][}| ||dxs|||df}|d |d<|d|d |d<|dDcgc]}||j%c}|d<]yycc}w) N)rr9c"|jSr)r/rs rr/z?MySQLDialect._correct_for_mysql_bugs_88718_96365..lowerI swwy rc|Srrrs rr/z?MySQLDialect._correct_for_mysql_bugs_88718_96365..lowerP src ttSr)r r,rrrzBMySQLDialect._correct_for_mysql_bugs_88718_96365..Z s D 1rrrrc 3K|]]\}}tjtjj|k(tj d|j D_yw)c3 K|]|\}}tjtjj|k(tj j tjjj|~ywr) r?and_ _info_columnsr'rfuncr/ column_namein_)rrrQs rrzMMySQLDialect._correct_for_mysql_bugs_88718_96365...h s_%3E7 !$$1OO$>$>%$G$'HHNN(5(C(C%&&)c'l !"sBBN)r?rrr' table_schemaor_r1)rr>rs rrzCMySQLDialect._correct_for_mysql_bugs_88718_96365..d sZ'HH%44>7=lln  sA#A% SCHEMANAME TABLENAME)rrrr)_casingrrr r6r?rr1r-rr'rrrwhererrrMr/)rrr4r/rschema_by_table_by_columnrecschtblcol_name conditionr-correct_for_wrong_fk_casedr>tnamecnamefkeyrec_brs rrz0MySQLDialect._correct_for_mysql_bugs_88718_963655 sV$ <<6 ! ! $.#5#5#I#I 1 2 " EC-.E2EFC,-.C 23 E)#.s3::8D E E %+D*I*I*KI(ZZ,,**++eI ""6* &?J$>OA(A H$uAG5=%,/0>@E5=%,/0=BG5=%,/0? H  d#45L9LMd#345*/{);%&)*6.3L.AD*+377I2J,+.E#))+&,'( a %x,s G1c |j|||fi|}|jDcgc] }|d|dd}}|jd|r|StjScc}w)Nrsqltext)rrc|dxsdSNr~rrs rrz4MySQLDialect.get_check_constraints.. qy/Crr)rck_constraintsr$rCcheck_constraints)rr4rr>rrrvckss rget_check_constraintsz"MySQLDialect.get_check_constraints s4t33  F .0 %33/ &\d9o >/ /  /0sE1CCEE / sA#c |j|||fi|}|jj|jdd}|d|iSt j S)N_commentr)rrrRrrC table_comment)rr4rr>rrrs rget_table_commentzMySQLDialect.get_table_comment sj4t33  F .0 ,,00DII;h1GN  G$ $%335 5rc Z|j|||fi|}g}|jD]}i}d} |d} | dk(r| dk(rd} n/| dvr| |d|jz<n| tjd| |d r|d |d |jz<|d |d D cgc]} | d  c} | d} |d D cic]} | d | d | d} } | r| |d|jz<| r| | d<|r|| d<|j | |j d|r|StjScc} wcc} w)NFrrUNIQUET)FULLTEXTSPATIALr5z-Converting unknown KEY type %s to a plain KEYrTz%s_with_parserrrQr)r column_namesrJrz %s_lengthrLc|dxsdSrrrs rrz*MySQLDialect.get_indexes.. s1V9#3rr) rrrr@r7r6r$rCindexes)rr4rr>rrrrvrLrJflavorrindex_d mysql_lengths r get_indexeszMySQLDialect.get_indexes s4t33  F .0 )+ %%& $D OF&\F"!22;A dii 78# CVH~BFC 0DII >? V /3I ?!1 ? 'G%)O qt7G!ad L;G dii 78"(-<)* NN7 #M& $N  3 4!wC'9'A'A'CC%!@s D#+ D(6 D(c |j|||fi|}|jDcgc]*}|ddk(r |d|dDcgc]}|d c}|dd,}}}|jd|r|StjScc}wcc}}w) Nrr rrQr)rrduplicates_indexc|dxsdSrrrs rrz5MySQLDialect.get_unique_constraints..rrr)rrr$rCunique_constraints) rr4rr>rrrrucss rget_unique_constraintsz#MySQLDialect.get_unique_constraints s4t33  F .0 $(( 0 6{h& F 36y> BCQ B$'K 0 0  /0 J%88: :!C0 sB B BBc |j}dj|jj||}|j |d||}|j j drtj||S)Nrrz CREATE TABLE) rrrr_show_create_tablerr r<NoSuchTableError)rr4 view_namer>rr|rr?s rget_view_definitionz MySQLDialect.get_view_definitions**HH  $ $ < rs rrz$MySQLDialect._parsed_state_or_create,s3!!   vvlD1 "  rcF|j}tj||S)zreturn the MySQLTableDefinitionParser, generate if needed. The deferred creation ensures that the dialect has retrieved server version information first. )rr%MySQLTableDefinitionParser)rrs r_tabledef_parserzMySQLDialect._tabledef_parser:s"++55dHEErc F|j}|j}dj|jj ||}|j |d||}|j |r'|j|d||} |j|| }|j||S)Nrr) rr&rrrr _check_view_describe_table_describe_to_createparse) rr4rr>rr|rTrr?rQs rr#zMySQLDialect._setup_parserEs**&&HH  $ $ < <   %% g&    c "**D'Y+G,,GC||C))rc|j}|jr|jdkrd|z}d}nd|z}d}|j|}|j||}|syt t t ||S)N)rzSHOW VARIABLES LIKE '%s'rz SELECT @@%srr)rrr]rsrr r)rr4 setting_namer|r? fetch_colshow_varr&s r_fetch_settingzMySQLDialect._fetch_settingas**  # #(@(@6(I,|;CI,.CI--c2  7 ; s9~6 6rctrrurys rrzMySQLDialect._detect_charsetts !##rcx|j|d}|d}n|dk(rd}n|dk(rd}n t|}||_|S)zSniff out identifier case sensitivity. Cached per-connection. This value can not change without a server restart. lower_case_table_namesrOFFONr)r1rr)rr4settingcss rrzMySQLDialect._detect_casingwsQ%%j2JK ?B%D\  rci}|j}|jd}|j||D] }|d||d<|S)zYPull the active COLLATIONS list from the server. Cached per-connection. zSHOW COLLATIONrr)rr]rm)rr4 collationsr|rr&s r_detect_collationszMySQLDialect._detect_collationssY  **  ' '(8 9((W5 (C!$QJs1v  (rc||j|d}|tjdd|_y|xsd|_y)Nsql_modez[Could not retrieve SQL_MODE; please ensure the MySQL user has permissions to SHOW VARIABLESr)r1r@r7 _sql_mode)rr4r7s rrzMySQLDialect._detect_sql_modes>%%j*= ? II?  DN$]DNrc|j}|sd}n+|jrt|}|dz|k(xrdxsd}d|v|_d|v|_y)z/Detect and adjust for the ANSI_QUOTES sql mode.rr ANSI_QUOTESNO_BACKSLASH_ESCAPESN)r>isdigitrrry)rr4modemode_nos rrzMySQLDialect._detect_ansiquotess[~~D \\^$iGaK7*= CD"/4"7#9"Drcyrrrr4rr|rs rrzMySQLDialect._show_create_tablercyrrrFs rrzMySQLDialect._show_create_tablerGrc||J|jj|}d|z} |jdj|}|j||}|st j|tt|djS#tj $r:}|j |jdk(rt j||d}~wwxYw)z&Run SHOW CREATE TABLE for a ``Table``.NzSHOW CREATE TABLE %sTr|r~rr) rr@r}r]r<rrerrrsrrstrip) rr4rr|rstrlrr&s rrzMySQLDialect._show_create_tables  $ $$00==eDI #i / --'+.ob!   W 5&&y1 1CQ &&((~~ ''/47**951<  s!BC!'5CC!cyrrrFs rr)zMySQLDialect._describe_table=@rcyrrrFs rr)zMySQLDialect._describe_tablerNrc||J|jj|}d|z}d\}} |jdj|}|j|| }|r|j|S#tj $r]}|j |j} | dk(rt j||| dk(rt jd|d ||d}~wwxYw#|r|jwwxYw) z7Run DESCRIBE for a ``Table`` and return processed rows.Nz DESCRIBE %sNNTrJr~iLzTable or view named z could not be reflected: r) rr@r}r]r<rrerrUnreflectableTableErrorrmr) rr4rr|rrLrlrowsrcodes rr)zMySQLDialect._describe_tables  $ $$00==eDI Y &D  11+/2!/"% ((W(=D  #>> //74<..y9q@T\55+4a9   s*!A6C)6C& AC!!C&&C))C>)NNN) rOptional[Callable[..., Any]]rrUrOptional[bool]rrrr)rr[rzSequence[IsolationLevel])rr[rr^rr)rr[rr^)r.rhrr)r4rYrr)r=rrr)rrVrrrr)r4rYrLrrr)TF) r4rYrLrrUrrVrrr)r4rYrz List[Any])rDBAPIModule.Errorr4z7Optional[Union[PoolProxiedConnection, DBAPIConnection]]rAzOptional[DBAPICursor]rrr)rlCursorResult[Any]r|rr1Union[Sequence[Row[Any]], Sequence[_DecodingRow]])rlrXr|rrz#Union[Row[Any], None, _DecodingRow])rlrXr|rrzOptional[_DecodingRow])rvrWrz Optional[int])r4rYrr) r4rYrrr>rrrrr) r4rYrrr>rrrrr)rr )r4rYr>rrrr List[str])r4rYrrr)rr)r4rYrrrrZ) r4rYrrr>rrrrr) r4rYrrr>rrrrzList[ReflectedColumn]) r4rYrrr>rrrrrd) r4rYrrr>rrrr#List[ReflectedForeignKeyConstraint])rr[r4rYrr) r4rYrrr>rrrrzList[ReflectedCheckConstraint]) r4rYrrr>rrrrre) r4rYrrr>rrrrzList[ReflectedIndex]) r4rYrrr>rrrrzList[ReflectedUniqueConstraint]) r4rYrrr>rrrrr) r4rYrrr>rrrrz_reflection.ReflectedState)rz&_reflection.MySQLTableDefinitionParser)r4rYr.rrr)r4rYrr)r4rYrDict[str, str]) r4rYrOptional[Table]r|rrrrrrQ) r4rYrrir|rrrrr) r4rYrr]r|rrrrr) r4rYrr]r|rrrrrY) r4rYrrir|rrrrrY) r4rYrr]r|rrrrrY)urrr__doc__rsupports_statement_cachesupports_altersupports_native_booleansupports_native_bitmax_identifier_lengthmax_index_name_lengthmax_constraint_name_lengthdiv_is_floordivsupports_native_enumreturns_native_bytesrsequences_optionalrr.supports_default_valuessupports_default_metavaluerrrLANY_AUTOINCREMENT"insertmanyvalues_implicit_sentinelsupports_sane_rowcountsupports_sane_multi_rowcountsupports_multivalues_insert#insert_null_pk_still_autoincrementssupports_commentsinline_commentsdefault_paramstylecolspecscte_follows_insertrstatement_compilerr ddl_compilerrrtype_compiler_cls ischema_namesrrrr>ryrrrir?rnrmrbIndexconstruct_argumentsrrrr' classmethodr2r7r5rrOrRrWrYr`rgrmrprsrerzrcacherrrrrrpropertyrprrr"rrrrrrrrrrr rrr rr@memoized_propertyr&r#r1rrr;rrrrr)rrrrrm s  D#N$  !#O",1( $!%!%$%$66'"#( "&*.'O!H&#L)!M.EH+EJ'+$ ((00 3+& gt_% gt_%  ' ''49 OO#   $9=:>%) *5 *8 *# *  *  * ) !  /8F - /- -*"/$/ /"$#L%(%?N% %4EG! H H H H  H  H! F F F F  F  F  L&   B?CE#E.;E :E?C # .;  , ?C # .;   $*$ $ H !% 111 1  1  11f !% *** *  *  **4 >B $ .; JM   ,/)b ::::##  "">B $ .; JM   ,>B $ .; JM   " !% 6 6 6 6  6  6 6 !% 0 0 0 0  0  0 0 !% 222 2  2 ' 22" !% -E-E-E -E  -E - -E-E^j2jj  jX !% FFF F  F ( FF$ !% 666 6  6  66  !% 5D5D5D 5D  5D  5D5Dn !% ;;; ;  ; ) ;;4 !%     .!%          $   FF !% *** *  * $ **67$7477 7&$0  + E     "&     "&#' ))) ) ! ) )8@@@ @  @ ; @@ "& @@@ @  @ ; @@"&#' %%% % ! % ; %rrcFeZdZUdZdddddddZded <dd Zdd Zdd Zy )rjzReturn unicode-decoded values based on type inspection. Smooth over data type issues (esp. with alpha driver versions) and normalize strings as Unicode regardless of user-configured driver encoding settings. koi8_rkoi8_uz utf-16-beutf8ujis)koi8rkoi8uutf16utf8mb4utf8mb3eucjpmsr\_encoding_compatch||_|"|jj|||_yd|_yr)rowproxyrrRr|)rrr|s rrz_DecodingRow.__init__6s<  "  ! ! % %gw 7  rc|j|}|jr+t|tr|j |jS|Sr)rr|rr$r%)rrPitems r __getitem__z_DecodingRow.__getitem__>s8}}U# <rr?r@enginerArrBengine.reflectionrCrDrErFrGrHrIrJrrK sql.compilerrLrM sql.schemarNrOrPrQrRrSrTrUrVdialects.mysqlrWdialects.mysql.dmlrX engine.baserY engine.cursorrZengine.interfacesr[r\r]r^r_r`rarbrcrdrerf engine.rowrg engine.urlrhrirjrksql.dmlrlrmrnro sql.functionsrprqrrrsr sql.type_apirt sql.visitorsrur;r rSET_REMSTimeMSSetMSEnum MSLongBlob MSMediumBlob MSTinyBlobMSBlobMSBinary MSVarBinaryMSNChar MSNVarCharMSCharMSString MSLongText MSMediumText MSTinyTextMSTextMSYear MSTimeStampMSBitMSSmallInteger MSTinyIntegerMSMediumInteger MSBigInteger MSNumeric MSDecimalMSDoubleMSRealMSFloat MSIntegerrroDoublerkEnum MatchTyperurzDefaultExecutionContextrr DDLCompilerrGenericTypeCompilerrrIdentifierPreparerrrr rrjrr!rrrrrs=`B!##  '20#' 3#8'% ,7)-4003:=4B3B:>!!!+!!%2''(=*5 ,bddRZZ.?                            ,,  g NNE OOV MM4 MM4   MM4 MM MM   % f% f% 3% D % w %  D % D%%w% f% D% W% U% 7%w%  D!%"#%$%%&*'%()%**+%, U-%./%0w1%2 33%45%6 D7%8 D9%:;%<=%>w?%@A%B DC%DE%F I% P, G;;, ^b H((b JB x++B J u44up Oh99O,, 7,o7))od%++\  CJJ~wr{+CJJ|WR[)CJJ}gbk*   r