%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyc

�
��4]c@s�	dZddlmZddlmZddlZddlZddlmZ	ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&dd!lm'Z'dd"lm(Z(dd#lm)Z)dd$lm*Z*dd%lm+Z+dd&lm,Z,dd'lm-Z-dd(lm.Z.dd)lm/Z/dd*lm0Z0d+d,lm1Z1d+d-lm2Z2d+d.lm3Z4d+d/lm5Z5d+d0lmZ6d+d1lm7Z7d+d2l8m9Z9d+dl8mZd+d3l5m:Z:d+d4l5m;Z;d+d5lm<Z<d+d6lm=Z=d+d7lm>Z>d+d8lm?Z?d+d9lm@Z@d+d:l7mAZAeBd;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�dddddddddd	d
ddd
ddddddddddddddddddd d;d�d�d�d�d�d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLg�ZCejDdMejEejFB�ZGejDdNejEejFB�ZHe*ZIeZJeZKeZLe!ZMe,ZNe=ZOe<ZPe@ZQe$ZRe&ZSeZTe/ZUe ZVe#ZWe.ZXe)ZYe0ZZe+Z[eZ\e(Z]e-Z^e"Z_eZ`e%ZaeZbeZce'ZdeZeeZfiee6ee6ee6e%e6jg6ee6jh6e*e6ji6ee6jj6ee6jk6ee6j6ee6jj6ee6jj6Zli#edF6e<dG6edO6e=dH6e>dP6edO6e?dQ6edR6edf6edq6edS6edT6ed~6ed�6ed�6edU6ed�6e d�6e!d�6e"d�6e#d�6e$dV6e&dW6e%d�6ed�6e(d�6e)dX6e*dY6e+dZ6e,d�6e-d�6e.d�6e@d6e/d6e0d[6Zmd\e9jnfd]��YZod^e:jpfd_��YZqd`e:jrfda��YZsdbe:jtfdc��YZudde:jvfde��YZwe2jxdfe9jyfdg��Y�Zzdhe{fdi��YZ|dS(js�m

.. dialect:: mysql
    :name: MySQL

Supported Versions and Features
-------------------------------

SQLAlchemy supports MySQL starting with version 4.1 through modern releases.
However, no heroic measures are taken to work around major missing
SQL features - if your server version does not support sub-selects, for
example, they won't work in SQLAlchemy either.

See the official MySQL documentation for detailed information about features
supported in any given server release.

.. _mysql_connection_timeouts:

Connection Timeouts and Disconnects
-----------------------------------

MySQL features 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:`.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
------------------------------------------------

MySQL'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"
       )

The MySQL dialect 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:`.Table` that is created in a MySQL 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``.

.. seealso::

    `The InnoDB Storage Engine
    <http://dev.mysql.com/doc/refman/5.0/en/innodb-storage-engine.html>`_ -
    on the MySQL website.

Case Sensitivity and Table Reflection
-------------------------------------

MySQL has 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
database itself, especially if database reflection features are
to be used.

.. _mysql_isolation_level:

Transaction Isolation Level
---------------------------

All MySQL dialects support setting of transaction isolation level both via a
dialect-specific parameter :paramref:`.create_engine.isolation_level` accepted
by :func:`.create_engine`, as well as the
:paramref:`.Connection.execution_options.isolation_level` argument as passed to
:meth:`.Connection.execution_options`. This feature works by issuing the
command ``SET SESSION TRANSACTION ISOLATION LEVEL <level>`` for each new
connection.  For the special AUTOCOMMIT isolation level, DBAPI-specific
techniques are used.

To set isolation level using :func:`.create_engine`::

    engine = create_engine(
                    "mysql://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 MySQL connection will return true for the value of
``SELECT @@autocommit;``.

.. versionadded:: 1.1 - added support for the AUTOCOMMIT isolation level.

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:`~.Column.autoincrement` argument of :class:`.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 MySQLdb and PyMySQL dialects.
From a MySQL point of view this means that the ``MySQLdb.cursors.SSCursor`` or
``pymysql.cursors.SSCursor`` class is used when building up the cursor which
will receive results.  The most typical way of invoking this feature is via the
:paramref:`.Connection.execution_options.stream_results` connection execution
option.   Server side cursors can also be enabled for all SELECT statements
unconditionally by passing ``server_side_cursors=True`` to
:func:`.create_engine`.

.. versionadded:: 1.1.4 - added server-side cursor support.

.. _mysql_unicode:

Unicode
-------

Charset Selection
~~~~~~~~~~~~~~~~~

Most MySQL 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 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 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 schema and/or server configuration may be
required.

.. seealso::

    `The utf8mb4 Character Set \
    <http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html>`_ - \
    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::

    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::

    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 <https://dev.mysql.com/doc/refman/5.7/en/charset-introducer.html>`_ - on the MySQL website


ANSI Quoting Style
------------------

MySQL features 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 ``sql_mode`` when a connection is first
established with a particular :class:`.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 Extensions
--------------------

Many of the MySQL 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 MySQL statement can be executed as a string as well.

Some limited direct support for MySQL extensions to SQL is currently
available.

* INSERT..ON DUPLICATE KEY UPDATE:  See
  :ref:`mysql_insert_on_duplicate_key_update`

* SELECT pragma, use :meth:`.Select.prefix_with` and :meth:`.Query.prefix_with`::

    select(...).prefix_with(['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])

* UPDATE with LIMIT::

    update(..., mysql_limit=10)

* optimizer hints, use :meth:`.Select.prefix_with` and :meth:`.Query.prefix_with`::

    select(...).prefix_with("/*+ NO_RANGE_OPTIMIZATION(t4 PRIMARY) */")

* index hints, use :meth:`.Select.with_hint` and :meth:`.Query.with_hint`::

    select(...).with_hint(some_table, "USE INDEX xyz")

.. _mysql_insert_on_duplicate_key_update:

INSERT...ON DUPLICATE KEY UPDATE (Upsert)
------------------------------------------

MySQL allows "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.dml.insert()` function, which provides
the generative method :meth:`~.mysql.dml.Insert.on_duplicate_key_update`::

    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'
    )

    conn.execute(on_duplicate_key_stmt)

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.dml.Insert.on_duplicate_key_update`
given column key values (usually the name of the column, unless it
specifies :paramref:`.Column.key`) as keys and literal or SQL expressions
as values::

    on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update(
        data="some data",
        updated_at=func.current_timestamp(),
    )

In a manner similar to that of :meth:`.UpdateBase.values`, other parameter
forms are accepted, including a single dictionary::

    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:`updates_order_parameters`.  Unlike the :class:`.Update` object,
no special flag is needed to specify the intent since the argument form is
this context is unambiguous::

    on_duplicate_key_stmt = insert_stmt.on_duplicate_key_update(
        [
            ("data", "some data"),
            ("updated_at", func.current_timestamp()),
        ],
    )

.. versionchanged:: 1.3 support for parameter-ordered UPDATE clause within
   MySQL ON DUPLICATE KEY UPDATE

.. warning::

    The :meth:`.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:`.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.dml.Insert.inserted` is available as an attribute on
the :class:`.mysql.dml.Insert` object; this object is a
:class:`.ColumnCollection` which contains all columns of the target
table::

    from sqlalchemy.dialects.mysql import insert

    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
    )
    conn.execute(do_update_stmt)

When rendered, the "inserted" namespace will produce the expression
``VALUES(<columnname>)``.

.. 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:`.ResultProxy.rowcount`


CAST Support
------------

MySQL documents the CAST operator as available in version 4.0.2.  When using
the SQLAlchemy :func:`.cast` function, SQLAlchemy
will not render the CAST token on MySQL before this version, based on server
version detection, instead rendering the internal expression directly.

CAST may still not be desirable on an early MySQL version post-4.0.2, as it
didn't add all datatype support until 4.1.1.   If your application falls into
this narrow area, the behavior of CAST can be controlled using the
:ref:`sqlalchemy.ext.compiler_toplevel` system, as per the recipe below::

    from sqlalchemy.sql.expression import Cast
    from sqlalchemy.ext.compiler import compiles

    @compiles(Cast, 'mysql')
    def _check_mysql_version(element, compiler, **kw):
        if compiler.dialect.server_version_info < (4, 1, 0):
            return compiler.process(element.clause, **kw)
        else:
            return compiler.visit_cast(element, **kw)

The above function, which only needs to be declared once
within an application, overrides the compilation of the
:func:`.cast` construct to check for version 4.1.0 before
fully rendering CAST; else the internal element of the
construct is rendered directly.


.. _mysql_indexes:

MySQL Specific Index Options
----------------------------

MySQL-specific extensions to the :class:`.Index` construct are available.

Index Length
~~~~~~~~~~~~~

MySQL provides 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`` parameter::

    Index('my_index', my_table.c.data, mysql_length=10)

    Index('a_b_idx', my_table.c.a, my_table.c.b, mysql_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 only allows 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.

.. versionadded:: 1.1.5

.. seealso::

    `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - 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')

As well as the ``mysql_using`` parameter on :class:`.PrimaryKeyConstraint`::

    PrimaryKeyConstraint("data", mysql_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:

http://dev.mysql.com/doc/refman/5.0/en/create-index.html

http://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")

.. versionadded:: 1.3


.. _mysql_foreign_keys:

MySQL Foreign Keys
------------------

MySQL's behavior regarding foreign keys has some important caveats.

Foreign Key Arguments to Avoid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MySQL does not support the foreign key arguments "DEFERRABLE", "INITIALLY",
or "MATCH".  Using the ``deferrable`` or ``initially`` keyword argument with
:class:`.ForeignKeyConstraint` or :class:`.ForeignKey` will have the effect of
these keywords being rendered in a DDL expression, which will then raise an
error on MySQL.  In order to use these keywords on a foreign key while having
them ignored on a MySQL backend, use a custom compile rule::

    from sqlalchemy.ext.compiler import compiles
    from sqlalchemy.schema import ForeignKeyConstraint

    @compiles(ForeignKeyConstraint, "mysql")
    def process(element, compiler, **kw):
        element.deferrable = element.initially = None
        return compiler.visit_foreign_key_constraint(element, **kw)

.. versionchanged:: 0.9.0 - the MySQL backend no longer silently ignores
   the ``deferrable`` or ``initially`` keyword arguments of
   :class:`.ForeignKeyConstraint` and :class:`.ForeignKey`.

The "MATCH" keyword is in fact more insidious, and is explicitly disallowed
by SQLAlchemy in conjunction with the MySQL backend.  This argument is
silently ignored by MySQL, 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 backend; as is the case with DEFERRABLE and
INITIALLY, custom compilation rules can be used to correct a MySQL
ForeignKeyConstraint at DDL definition time.

.. versionadded:: 0.9.0 - the MySQL backend will raise a
   :class:`.CompileError` when the ``match`` keyword is used with
   :class:`.ForeignKeyConstraint` or :class:`.ForeignKey`.

Reflection of Foreign Key Constraints
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not all MySQL 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=True
       )

.. seealso::

    :ref:`mysql_storage_engines`

.. _mysql_unique_constraints:

MySQL 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 when emitting DDL to create
these constraints.  However, MySQL does not have a unique constraint
construct that is separate from a unique index; that is, the "UNIQUE"
constraint on MySQL is equivalent to creating a "UNIQUE INDEX".

When reflecting these constructs, the :meth:`.Inspector.get_indexes`
and the :meth:`.Inspector.get_unique_constraints` methods will **both**
return an entry for a UNIQUE index in MySQL.  However, when performing
full table reflection using ``Table(..., autoload=True)``,
the :class:`.UniqueConstraint` construct is
**not** part of the fully reflected :class:`.Table` construct under any
circumstances; this construct is always represented by a :class:`.Index`
with the ``unique=True`` setting present in the :attr:`.Table.indexes`
collection.


.. _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::

    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
<http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html
#sysvar_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://scott:tiger@localhost/test", echo=True)
    m.create_all(e)

output::

    CREATE TABLE ts_test (
        a INTEGER,
        b INTEGER NOT NULL,
        c TIMESTAMP NULL,
        d TIMESTAMP NOT NULL
    )

.. versionchanged:: 1.0.0 - SQLAlchemy now renders NULL or NOT NULL in all
   cases for TIMESTAMP columns, to accommodate
   ``explicit_defaults_for_timestamp``.  Prior to this version, it will
   not render "NOT NULL" for a TIMESTAMP column that is ``nullable=False``.

i����(tarray(tdefaultdictNi(t
reflection(tENUM(tSET(tJSON(t
JSONIndexType(tJSONPathType(t
_FloatType(t_IntegerType(t
_MatchType(t_NumericType(t_StringType(tBIGINT(tBIT(tCHAR(tDATETIME(tDECIMAL(tDOUBLE(tFLOAT(tINTEGER(tLONGBLOB(tLONGTEXT(t
MEDIUMBLOB(t	MEDIUMINT(t
MEDIUMTEXT(tNCHAR(tNUMERIC(tNVARCHAR(tREAL(tSMALLINT(tTEXT(tTIME(t	TIMESTAMP(tTINYBLOB(tTINYINT(tTINYTEXT(tVARCHAR(tYEARi(texc(tlog(tschema(tsql(ttypes(tutil(tdefault(tcompiler(telements(tBINARY(tBLOB(tBOOLEAN(tDATE(t	VARBINARY(ttopologicalt
accessibletaddtalltaltertanalyzetandtastasct
asensitivetbeforetbetweentbiginttbinarytblobtbothtbytcalltcascadetcasetchangetchart	charactertchecktcollatetcolumnt	conditiont
constrainttcontinuetconverttcreatetcrosstcurrent_datetcurrent_timetcurrent_timestamptcurrent_usertcursortdatabaset	databasestday_hourtday_microsecondt
day_minutet
day_secondtdectdecimaltdeclareR-tdelayedtdeletetdesctdescribet
deterministictdistincttdistinctrowtdivtdoubletdroptdualteachtelsetelseiftenclosedtescapedtexiststexittexplaintfalsetfetchtfloattfloat4tfloat8tfortforcetforeigntfromtfulltexttgranttgroupthavingt
high_prioritythour_microsecondthour_minutethour_secondtiftignoretintindextinfiletinnertinouttinsensitivetinserttinttint1tint2tint3tint4tint8tintegertintervaltintotistiteratetjointkeytkeystkilltleadingtleavetlefttliketlimittlineartlinestloadt	localtimetlocaltimestamptlocktlongtlongblobtlongtexttlooptlow_prioritytmaster_ssl_verify_server_certtmatcht
mediumblobt	mediumintt
mediumtextt	middleinttminute_microsecondt
minute_secondtmodtmodifiestnaturaltnottno_write_to_binlogtnulltnumerictontoptimizetoptiont
optionallytortordertouttoutertoutfilet	precisiontprimaryt	proceduretpurgetrangetreadtreadst	read_onlyt
read_writetrealt
referencestregexptreleasetrenametrepeattreplacetrequiretrestricttreturntrevoketrighttrlikeR)tschemastsecond_microsecondtselectt	sensitivet	separatortsettshowtsmallinttspatialtspecificR*tsqlexceptiontsqlstatet
sqlwarningtsql_big_resulttsql_calc_found_rowstsql_small_resulttssltstartingt
straight_jointtablet
terminatedtthenttinyblobttinyintttinytextttottrailingttriggerttruetundotuniontuniquetunlocktunsignedtupdatetusagetusetusingtutc_datetutc_timet
utc_timestamptvaluest	varbinarytvarchartvarcharactertvaryingtwhentwheretwhiletwithtwritetx509txort
year_monthtzerofilltcolumnstfieldst
privilegestsonamettablestgeneraltignore_server_idstmaster_heartbeat_periodtmaxvaluetresignaltsignaltslowtgettio_after_gtidstio_before_gtidstmaster_bindtone_shott	partitiontsql_after_gtidstsql_before_gtidst	generatedtoptimizer_costststoredtvirtualtadmint	cume_disttemptytexcepttfirst_valuetgroupingtfunctiontgroupst
json_tablet
last_valuet	nth_valuetntiletoftovertpercent_ranktpersisttpersist_onlytrankt	recursivetroletrowtrowst
row_numbertsystemtwindows@\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|LOAD +DATA|REPLACE)s%\s*SET\s+(?:(?:GLOBAL|SESSION)\s+)?\wtbittbooleantdatetdatetimetenumtfixedtjsontnchartnvarcharttextttimet	timestamptyeartMySQLExecutionContextcBseZd�Zd�ZRS(cCs
tj|�S(N(t
AUTOCOMMIT_RER�(tselft	statement((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytshould_autocommit_text�scCs/|jjr"|jj|jj�St��dS(N(tdialecttsupports_server_side_cursorst_dbapi_connectionRYt	_sscursortNotImplementedError(RT((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytcreate_server_side_cursor�s(t__name__t
__module__RVR\(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRR�s	t
MySQLCompilercBs	eZeZejjj�Zejidd6�d�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd	�Zdd
�Zd�Zd�Zd
�Zd�Zd�Zed�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!RS(tmillisecondtmillisecondscKsd|j|�S(Nsrand%s(tfunction_argspec(RTtfntkw((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_random_func�scKsdS(Ns	SYSDATE()((RTRcRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_sysdate_func�scKs,d|j|j|�|j|j|�fS(NsJSON_EXTRACT(%s, %s)(tprocessR�R�(RTRBtoperatorRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_json_getitem_op_binary�scKs,d|j|j|�|j|j|�fS(NsJSON_EXTRACT(%s, %s)(RgR�R�(RTRBRhRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt!visit_json_path_getitem_op_binary�scs��jr�g�jD]}tj|�^q}t|�}g|D].}||jjjkrA|jjj|^qAg|jjjD]}|j|kr�|^q�}n|jjj}g}xU�fd�|D�D]=}	�j|	j}
tj	|
�r1tj
d|
d|	j�}
|j
|
j�dt�}n�t|
tj
�r�|
jjr�|
j�}
|	j|
_|j
|
j�dt�}n_t|
tj�r�|
j�jkr�d|jj|	j�d}n|j
|
j�dt�}|jj|	j�}|jd||f�q�Wt�j�td�|D��}
|
rstjd|jjjd	jd
�|
D��f�ndd	j|�S(Nc3s'|]}|j�jkr|VqdS(N(R�R�(t.0tcol(ton_duplicate(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�sttype_t
use_schemasVALUES(t)s%s = %scss|]}|jVqdS(N(R�(Rktc((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�ssFAdditional column names not matching any column keys in table '%s': %ss, css|]}d|VqdS(s'%s'N((RkRq((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�ssON DUPLICATE KEY UPDATE (t_parameter_orderingR/t_column_as_keyR�RUR�RqR�R�t_is_literalt
BindParametertNonettypeRgt
self_grouptFalset
isinstancet_isnullt_clonetColumnClausetinserted_aliastpreparertquotetnametappendR,twarnR�(RTRmRdR�tparameter_orderingtordered_keysRqtcolstclausesRNtvalt
value_textt	name_texttnon_matching((RmsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_on_duplicate_key_update�s@	"
+5 #!cKs,d|j|j|�|j|j|�fS(Nsconcat(%s, %s)(RgR�R�(RTRBRhRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_concat_op_binary�scKs,d|j|j|�|j|j|�fS(Ns'MATCH (%s) AGAINST (%s IN BOOLEAN MODE)(RgR�R�(RTRBRhRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_match_op_binary�scCs|S(N((RTR�RN((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_from_hint_textscKsz|dkr$|jj|j�}nt|tj�rL|j||j|�St|tj	�r{t
|dt�rtdSdSn�t|tj�r�dSt|tj
tjtjtjf�r�|jjj|�St|tj�rt|ttf�rtj|�}|jjj|�St|tj�r+dSt|tj�rAdSt|tj�rr|jjj|�jdd�SdSdS(	NR�sUNSIGNED INTEGERsSIGNED INTEGERRR0RRR(RvRwtdialect_implRWRztsqltypest
TypeDecoratortvisit_typeclausetimpltIntegertgetattrRyR!RtDateTimetDatetTimet
type_compilerRgtStringRRRt_adapt_string_for_castt_BinaryRRR�(RTt
typeclauseRnRdtadapted((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�s:
cKs�|jjs2tjd�|j|jj�|�S|j|j�}|dkr�tjd|jj	j|jj
��|j|jj�|�Sd|j|j|�|fS(NsFCurrent MySQL version does not support CAST; the CAST will be skipped.sEDatatype %s does not support CAST on MySQL; the CAST will be skipped.sCAST(%s AS %s)(RWt_supports_castR,R�RgtclauseRxR�RvR�Rw(RTtcastRdRn((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_cast,scCs@tt|�j||�}|jjr<|jdd�}n|S(Ns\s\\(tsuperR_trender_literal_valueRWt_backslash_escapesR�(RTtvalueRn((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�@scKsdS(NR�((RTtelementRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_trueHscKsdS(NRv((RTR�Rd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_falseKscKs;t|jtj�r&|jj�dS|jr3dSdSdS(s�Add special MySQL keywords in place of DISTINCT.

        .. note::

          this usage is deprecated.  :meth:`.Select.prefix_with`
          should be used for special keywords at the start
          of a SELECT.

        t s	DISTINCT tN(Rzt	_distinctR,tstring_typestupper(RTR�Rd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_select_precolumnsNs

	cKs|jrd}n|jr$d}nd}dj|j|jdt|�||j|jdt|�d|j|j|�f�S(Ns FULL OUTER JOIN s LEFT OUTER JOIN s INNER JOIN R�tasfroms ON (tfulltisouterR�RgR�tTrueR�tonclause(RTR�R�tkwargst	join_type((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_join_s				cKs|jjrdSdSdS(Ns LOCK IN SHARE MODEs FOR UPDATE(t_for_update_argR�(RTR�Rd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytfor_update_clauseqscKs�|j|j}}|dkr/|dkr/dS|dk	r�|dkrad|j||�dfSd|j||�|j||�fSnd|j||�fSdS(NR�s 
 LIMIT %s, %st18446744073709551615s 
 LIMIT %s(t
_limit_clauset_offset_clauseRvRg(RTR�Rdtlimit_clauset
offset_clause((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�ws

cCs5|jjd|jjd�}|r-d|SdSdS(Ns%s_limitsLIMIT %s(R�R RWR�Rv(RTtupdate_stmtR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytupdate_limit_clause�scs-dj��fd�|gt|�D��S(Ns, c3s'|]}|j�dt��VqdS(R�N(t_compiler_dispatchR�(Rktt(RdRT(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�s(R�tlist(RTR�t
from_tabletextra_fromsRd((RdRTsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytupdate_tables_clause�scKsdS(N(Rv(RTR�R�R�t
from_hintsRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytupdate_from_clause�scCs4t}|rt}n|j|dtdtd|�S(s=If we have extra froms make sure we render any alias as hint.R�tiscrudtashint(RyR�R�(RTtdelete_stmtR�R�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdelete_table_clause�s
	cs.ddj���fd�|g|D��S(s4Render the DELETE .. USING clause specific to MySQL.sUSING s, c3s-|]#}|j�dtd���VqdS(R�t	fromhintsN(R�R�(RkR�(R�RdRT(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�s(R�(RTR�R�R�R�Rd((R�RdRTsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdelete_extra_from_clause�s	cCsHdidjd�t|�D��d6djd�t|�D��d6S(NsASELECT %(outer)s FROM (SELECT %(inner)s) as _empty_set WHERE 1!=1s, css|]\}}d|VqdS(s1 AS _in_%sN((RktidxRn((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�sR�css|]\}}d|VqdS(s_in_%sN((RkR�Rn((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�sR�(R�t	enumerate(RTt
element_types((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_empty_set_expr�sN("R]R^R�t'render_table_with_column_in_update_fromR.tSQLCompilertextract_maptcopyR�ReRfRiRjR�R�R�R�RvR�R�R�R�R�R�RyR�R�R�R�R�R�R�R�R�(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR_�s4					5			&							(							tMySQLDDLCompilercBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cKsI|jj|�|jjj|jd|�g}t|jj|j�tj	�}|j
sj|jd�n|j
r�|r�|jd�n|j|�}|dk	r�|jd|�n|j}|dk	r�|jj|tj��}|jd|�n|jdk	r<||jjkr<|jdkr<|jd�ndj|�S(	sBuilds column DDL.ttype_expressionsNOT NULLtNULLsDEFAULT sCOMMENT tAUTO_INCREMENTR�N(Rt
format_columnRWR�RgRwRzt_unwrapped_dialect_implR�R!tnullableR�tget_column_default_stringRvtcommenttsql_compilerR�R�R�t_autoincrement_columntserver_defaultR�(RTRNRdtcolspectis_timestampR-R�tliteral((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_column_specification�s.			c
s�g}t�fd�|jj�D��}|jdk	rJ|j|d<nddddg}t|�j|�}t|�j|�}x�tj	ddg|�D]�}||}|t
jkr��jj
|tj��}n|dkr�|jdd�}nd}	|dkrd}	n|j|	j||f��q�Wx�tj	ddddddg|�D]q}||}|t
jkr��jj
|tj��}n|jdd�}d}	|j|	j||f��q]Wdj|�S(s9Build table-level CREATE options like ENGINE and COLLATE.c3sT|]J\}}|jd�jj�r|t�jj�dj�|fVqdS(s%s_iN(t
startswithRWR�tlenR�(Rktktv(RT(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>s	tCOMMENTtPARTITION_BYt
PARTITIONSt
SUBPARTITIONStSUBPARTITION_BYtDEFAULT_CHARSETtCOLLATEtDEFAULT_CHARACTER_SETtDATA_DIRECTORYtINDEX_DIRECTORYt
CHARACTER_SETtDEFAULT_COLLATEt_R�t=t
TABLESPACEsDEFAULT CHARACTER SETs
CHARACTER SETN(R�R�(R�R�(R�R�R�R�R�R�(R�sDEFAULT CHARACTER SETs
CHARACTER SETR�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(tdictR�titemsR�RvR�t
differencetintersectionR5tsortt_reflectiont_options_of_type_stringR�R�R�R�R�R�R�(
RTR�t
table_optstoptstpartition_optionstnonpart_optionstpart_optionstopttargtjoiner((RTsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytpost_create_table�sh		

				 	

	 c
s�|j}|j|�|j}|j|j�}g|jD]$}|jj|dtdt	�^q;}|j
|�}d}	|jr�|	d7}	n|jj
dd�}
|
r�|	|
d7}	n|	d||f7}	|jdd	��dk	rLt�t�r*d
j�fd�t|j|�D��}q[d
j�fd�|D��}nd
j|�}|	d
|7}	|jdd}|dk	r�|	d|f7}	n|jdd}|dk	r�|	d|j|�7}	n|	S(Nt
include_tablet
literal_bindssCREATE sUNIQUE tmysql_prefixR�sINDEX %s ON %s tmysqltlengths, c3se|][\}}|j�kr5d|�|jfn'|�krUd|�|fnd|VqdS(s%s(%d)s%sN(R�(RkRltexpr(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>rsc3s|]}d|�fVqdS(s%s(%d)N((RkRl(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>ss(%s)twith_parsers WITH PARSER %sRs	 USING %s(R�t_verify_index_tableRtformat_tableR�texpressionsR�RgRyR�t_prepared_index_nameR�R�R Rvtdialect_optionsRzR�R�tzipR�(
RTRSRdR�RR�RRR�RNtindex_prefixtparserR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_create_indexRs>	
	1	
cCsPtt|�j|�}|jdd}|rL|d|jj|�7}n|S(NRRs	 USING %s(R�R�tvisit_primary_key_constraintRRR�(RTRPRNR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�s	cCs5|j}d|j|dt�|jj|j�fS(Ns
DROP INDEX %s ON %stinclude_schema(R�RRyRRR�(RTRlR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_drop_index�s	cCs�|j}t|tj�r6d}|jj|�}n�t|tj�rWd}d}n�t|tj�r�d}|jj|�}nZt|tj�r�|j	j
r�d}nd}|jj|�}nd}|jj|�}d|jj|j�||fS(NsFOREIGN KEY sPRIMARY KEY R�sINDEX sCONSTRAINT sCHECK sALTER TABLE %s DROP %s%s(
R�Rzt	sa_schematForeignKeyConstraintRtformat_constrainttPrimaryKeyConstrainttUniqueConstrainttCheckConstraintRWt_is_mariadbRR�(RTRlRPtqualtconst((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_drop_constraint�s*			cCs%|jdk	r!tjd��ndS(NsjMySQL ignores the 'MATCH' keyword while at the same time causes ON UPDATE/ON DELETE clauses to be ignored.R�(R�RvR'tCompileError(RTRP((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdefine_constraint_match�scCs8d|jj|j�|jj|jjtj��fS(NsALTER TABLE %s COMMENT %s(RRR�R�R�R�R�R�(RTRS((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_set_table_comment�s	cCsd|jj|j�S(NsALTER TABLE %s COMMENT ''(RRR�(RTRS((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_drop_table_comment�scCs>d|jj|jj�|jj|j�|j|j�fS(NsALTER TABLE %s CHANGE %s %s(RRR�R�R�R�(RTRS((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_set_column_comment�s(R]R^R�R
RRRR'R)R*R+R,(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��s	+	S	=							tMySQLTypeCompilercBsgeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(RS('cCsC|j|�s|S|jr)|d7}n|jr?|d7}n|S(sAExtend a numeric-type declaration with MySQL specific extensions.s	 UNSIGNEDs	 ZEROFILL(t_mysql_typeR�R(RTRntspec((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_extend_numeric�s	
	
cs��fd�}|d�r1d|d�}n0|d�rFd}n|d�r[d}nd}|d�r}d	�j}n|d
�r�d}nd}|d�r�d
jgd||fD]}|dk	r�|^q��Sd
jg|||fD]}|dk	r�|^q��S(s�Extend a string-type declaration with standard SQL CHARACTER SET /
        COLLATE annotations and MySQL specific extensions.

        cst�|�j|��S(N(R�R (R�(tdefaultsRn(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytattr�stcharsetsCHARACTER SET %stasciitASCIItunicodetUNICODEt	collations
COLLATE %sRBR0tnationalR�tNATIONALN(RvR8R�(RTRnR1R/R2R3R8Rq((R1RnsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_extend_string�s$			/cCst|ttf�S(N(RzRR(RTRn((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR.scKsx|jdkr|j|d�S|jdkrL|j|di|jd6�S|j|di|jd6|jd6�SdS(NRsNUMERIC(%(precision)s)R�s!NUMERIC(%(precision)s, %(scale)s)tscale(R�RvR0R<(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_NUMERIC	scKsx|jdkr|j|d�S|jdkrL|j|di|jd6�S|j|di|jd6|jd6�SdS(NRsDECIMAL(%(precision)s)R�s!DECIMAL(%(precision)s, %(scale)s)R<(R�RvR0R<(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_DECIMALscKsZ|jdk	rF|jdk	rF|j|di|jd6|jd6�S|j|d�SdS(Ns DOUBLE(%(precision)s, %(scale)s)R�R<R(R�RvR<R0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_DOUBLE'scKsZ|jdk	rF|jdk	rF|j|di|jd6|jd6�S|j|d�SdS(NsREAL(%(precision)s, %(scale)s)R�R<R(R�RvR<R0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_REAL1scKs�|j|�rM|jdk	rM|jdk	rM|j|d|j|jf�S|jdk	rv|j|d|jf�S|j|d�SdS(Ns
FLOAT(%s, %s)s	FLOAT(%s)R(R.R<RvR�R0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_FLOAT;scKsP|j|�r<|jdk	r<|j|di|jd6�S|j|d�SdS(NsINTEGER(%(display_width)s)t
display_widthR(R.RBRvR0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_INTEGERKscKsP|j|�r<|jdk	r<|j|di|jd6�S|j|d�SdS(NsBIGINT(%(display_width)s)RBR
(R.RBRvR0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_BIGINTUscKsP|j|�r<|jdk	r<|j|di|jd6�S|j|d�SdS(NsMEDIUMINT(%(display_width)s)RBR(R.RBRvR0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_MEDIUMINT_scKsI|j|�r5|jdk	r5|j|d|j�S|j|d�SdS(NsTINYINT(%s)R#(R.RBRvR0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_TINYINTiscKsP|j|�r<|jdk	r<|j|di|jd6�S|j|d�SdS(NsSMALLINT(%(display_width)s)RBR(R.RBRvR0(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_SMALLINTqscKs"|jdk	rd|jSdSdS(NsBIT(%s)R(RRv(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt	visit_BIT{scKs%t|dd�rd|jSdSdS(NtfspsDATETIME(%d)R(R�RvRI(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_DATETIME�scKsdS(NR3((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_DATE�scKs%t|dd�rd|jSdSdS(NRIsTIME(%d)R (R�RvRI(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_TIME�scKs%t|dd�rd|jSdSdS(NRIs
TIMESTAMP(%d)R!(R�RvRI(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_TIMESTAMP�scKs"|jdkrdSd|jSdS(NR&sYEAR(%s)(RBRv(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_YEAR�scKs:|jr#|j|id|j�S|j|id�SdS(NsTEXT(%d)R(RR;(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_TEXT�s	cKs|j|id�S(NR$(R;(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_TINYTEXT�scKs|j|id�S(NR(R;(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_MEDIUMTEXT�scKs|j|id�S(NR(R;(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_LONGTEXT�scKs@|jr#|j|id|j�Stjd|jj��dS(NsVARCHAR(%d)s'VARCHAR requires a length on dialect %s(RR;R'R(RWR�(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_VARCHAR�s	cKsA|jr*|j|idi|jd6�S|j|id�SdS(NsCHAR(%(length)s)RR(RR;(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_CHAR�s	cKsN|jr1|j|itd6di|jd6�Stjd|jj��dS(NR9sVARCHAR(%(length)s)Rs(NVARCHAR requires a length on dialect %s(RR;R�R'R(RWR�(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_NVARCHAR�s	
cKsO|jr1|j|itd6di|jd6�S|j|itd6d�SdS(NR9sCHAR(%(length)s)RR(RR;R�(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_NCHAR�s	
cKsd|jS(Ns
VARBINARY(%d)(R(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_VARBINARY�scKsdS(NR((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_JSON�scKs
|j|�S(N(t
visit_BLOB(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_large_binary�scKs9|jstt|�j|�S|jd||j�SdS(NR(tnative_enumR�R-t
visit_enumt_visit_enumerated_valuestenums(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR\�s	cKs|jrd|jSdSdS(NsBLOB(%d)R1(R(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRY�s	cKsdS(NR"((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_TINYBLOB�scKsdS(NR((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_MEDIUMBLOB�scKsdS(NR((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytvisit_LONGBLOB�scCsZg}x+|D]#}|jd|jdd��q
W|j|id|dj|�f�S(Ns'%s't's''s%s(%s)t,(R�R�R;R�(RTR�Rntenumerated_valuestquoted_enumste((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR]�s

!cKs|jd||j�S(NR(R]t_enumerated_values(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_ENUM�scKs|jd||j�S(NR(R]Rg(RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt	visit_SETscKsdS(NtBOOL((RTRnRd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
visit_BOOLEANs()R]R^R0R;R.R=R>R?R@RARCRDRERFRGRHRJRKRLRMRNRORPRQRRRSRTRURVRWRXRZR\RYR_R`RaR]RhRiRk(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR-�sN		"				
	
		
	
	
		
																									tMySQLIdentifierPreparercBs#eZeZed�Zd�ZRS(cKs;|sd}nd}tt|�j|d|d|�dS(Nt`t"t
initial_quotetescape_quote(R�Rlt__init__(RTRWtserver_ansiquotesRdR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRq
s
	cGs2tg|D]!}|dk	r
|j|�^q
�S(s4Unilaterally identifier-quote any number of strings.N(ttupleRvtquote_identifier(RTtidsti((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_quote_free_identifierss(R]R^tRESERVED_WORDStreserved_wordsRyRqRw(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRl	s
tMySQLDialectcBs�eZdZdZeZeZdZdZ	eZ
eZeZeZ
eZeZdZeZeZeZeZeZeZeZeZeZejidBd6fe!j"idBd6fej#idBd6fej$idBd6dBd6dBd	6dBd
6fgZ%dBdBdBd�Z&d�Z'e(d
dddg�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2eed�Z3eed�Z4d�Z5d�Z6dBd�Z7dBd�Z8dBd �Z9d!�Z:d"�Z;dBd#�Z<d$�Z=d%�Z>e?d&��Z@e?d'��ZAe?d(��ZBe?d)��ZCe?d*��ZDeEjFd+��ZGeEjFdBd,��ZHeEjFdBd-��ZIeEjFdBd.��ZJeEjFdBd/��ZKeEjFdBd0��ZLeEjFdBd1��ZMd2�ZNeEjFdBd3��ZOeEjFdBd4��ZPeEjFdBd5��ZQeEjFdBd6��ZReEjFdBd7��ZSdBd8�ZTeUjVd9��ZWeEjFdBd:��ZXd;�ZYd<�ZZd=�Z[d>�Z\d?�Z]dBdBd@�Z^dBdBdA�Z_RS(CsMDetails of the MySQL dialect.
    Not used directly in application code.
    Ri�i@tformatt*R�RRtprefixRcKsB|jdd�tjj||�||_||_||_dS(Ntuse_ansiquotes(tpopRvR-tDefaultDialectRqtisolation_levelt_json_serializert_json_deserializer(RTR�tjson_serializertjson_deserializerR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRqVs
		cs*�jdk	r"�fd�}|SdSdS(Ncs�j|�j�dS(N(tset_isolation_levelR�(tconn(RT(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytconnectfs(R�Rv(RTR�((RTsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
on_connectcstSERIALIZABLEsREAD UNCOMMITTEDsREAD COMMITTEDsREPEATABLE READcCsA|jdd�}t|d�r-|j}n|j||�dS(NR�R�t
connection(R�thasattrR�t_set_isolation_level(RTR�tlevel((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�vscCsu||jkr=tjd||jdj|j�f��n|j�}|jd|�|jd�|j�dS(NsLInvalid value '%s' for isolation_level. Valid isolation levels for %s are %ss, s*SET SESSION TRANSACTION ISOLATION LEVEL %stCOMMIT(t_isolation_lookupR't
ArgumentErrorR�R�RYtexecutetclose(RTR�R�RY((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��s%
cCs�|j�}|jr4|jd	kr4|jd�n
|jd�|j�d}|j�tjr�t|t	�r�|j
�}n|j�jdd�S(
NiiisSELECT @@transaction_isolationsSELECT @@tx_isolationit-R�(iii(
RYt	_is_mysqltserver_version_infoR�tfetchoneR�R,tpy3kRztbytestdecodeR�R�(RTR�RYR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_isolation_level�s

cCsp|j}|j�}|jd�|j�d}|j�tjrct|t�rc|j	�}n|j
|�S(NsSELECT VERSION()i(R�RYR�R�R�R,R�RzR�R�t_parse_server_version(RTR�t	dbapi_conRYR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_get_server_version_info�s	

cCs�g}tjd�}x�|j|�D]v}y|jt|��Wq%tk
r�tjd|�}|r�|jd�|j�D��q�|j|�q%Xq%Wt	|�S(Ns[.\-]s(.*)(MariaDB)(.*)css|]}|r|VqdS(N((Rktg((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pys	<genexpr>�s(
tretcompiletsplitR�R�t
ValueErrorR�textendR3Rs(RTR�tversiontrtntmariadb((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��s
 cCshy|j�WnStk
rc|jdkr]tj�dj}|r]|ddkr]dSn�nXdS(	sExecute a COMMIT.iiiiii(N(iii(tcommitt	ExceptionR�tsystexc_infotargs(RTtdbapi_connectionR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt	do_commit�s	
cCshy|j�WnStk
rc|jdkr]tj�dj}|r]|ddkr]dSn�nXdS(	sExecute a ROLLBACK.iiiiii(N(iii(trollbackR�R�R�R�R�(RTR�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_rollback�s
cCs |jtjd�d|�dS(Ns
XA BEGIN :xidtxid(R�R*RN(RTR�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_begin_twophase�scCs<|jtjd�d|�|jtjd�d|�dS(NsXA END :xidR�sXA PREPARE :xid(R�R*RN(RTR�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_prepare_twophase�scCsE|s%|jtjd�d|�n|jtjd�d|�dS(NsXA END :xidR�sXA ROLLBACK :xid(R�R*RN(RTR�R�tis_preparedtrecover((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_rollback_twophase�scCs9|s|j||�n|jtjd�d|�dS(NsXA COMMIT :xidR�(R�R�R*RN(RTR�R�R�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_commit_twophase�scCs5|jd�}g|D]}|dd|d!^qS(Ns
XA RECOVERtdataitgtrid_length(R�(RTR�t	resultsetR@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytdo_recover_twophase�scCsmt||jj|jjf�r4|j|�dkSt||jj|jjf�redt|�kStSdS(Ni�i�i�i�is(0, '')(i�i�i�i�i(	RztdbapitOperationalErrortProgrammingErrort_extract_error_codetInterfaceErrort
InternalErrortstrRy(RTRfR�RY((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
is_disconnect�scCs&g|j�D]}t||�^q
S(sMProxy result rows to smooth over MySQL-Python driver
        inconsistencies.(tfetchallt_DecodingRowProxy(RTtrpR3R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_compat_fetchall	scCs'|j�}|rt||�SdSdS(sNProxy a result row to smooth over MySQL-Python driver
        inconsistencies.N(R�R�Rv(RTR�R3R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_compat_fetchone	s
cCs'|j�}|rt||�SdSdS(sNProxy a result row to smooth over MySQL-Python driver
        inconsistencies.N(tfirstR�Rv(RTR�R3R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt
_compat_first	s
cCs
t��dS(N(R[(RTt	exception((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�	scCs|jd�j�S(NsSELECT DATABASE()(R�tscalar(RTR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_get_default_schema_name	sc	Cs�dj|jj||��}d|}d}z{y?|jdt�j|�}|j�dk	}|j�|SWn5t	j
k
r�}|j|j�dkr�t
S�nXWd|r�|j�nXdS(Nt.sDESCRIBE %stskip_user_error_eventsiz(R�tidentifier_preparerRwRvtexecution_optionsR�R�R�R�R't
DBAPIErrorR�torigRy(	RTR�t
table_nameR)t	full_nametsttrsthaveRf((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt	has_table 	s&	
			
cCs�|j|�|_|j|�|j|�|j|�|jr`|j|d|j�|_ntj	j
||�|jo�|jdk|_
|j�dS(NRri(i(t_detect_charsett_connection_charsett_detect_sql_modet_detect_ansiquotest_detect_casingt_server_ansiquotesRR�R-R�t
initializeR$R�t_needs_correct_for_88718t_warn_for_known_db_issues(RTR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�C	s


	cCsH|jrD|j}|dkrD|dkrDtjd|f�qDndS(Ni
ii	s`MariaDB %r 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.(i
i(i
ii	(R$t _mariadb_normalized_version_infoR,R�(RTtmdb_version((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�W	s		cCs|jod|jkS(NtMariaDB(R�(RT((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR$e	scCs|jS(N(R$(RT((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�k	scCs|jo|jdkS(Ni
i(i
i(R$R�(RT((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_is_mariadb_102o	scCs8|jr-|jjd�}|j|d|!S|jSdS(NR�i(R$R�R�(RTR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�v	s	cCs|jdkp|jdkS(Niii(iii(R�Rv(RT((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��	scKs*|jd�}g|D]}|d^qS(NsSHOW schemasi(R�(RTR�RdR�R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_schema_names�	scKs�|d	k	r|}n	|j}|j}|jd
kr|jd|jj|��}g|j|d|�D]}|d^qkS|jd|jj|��}g|j|d|�D] }|ddkr�|d^q�Sd	S(s1Return a Unicode SHOW TABLES from a given schema.iiisSHOW TABLES FROM %sR3sSHOW FULL TABLES FROM %sis
BASE TABLEN(iii(Rvtdefault_schema_nameR�R�R�R�RtR�(RTR�R)Rdtcurrent_schemaR3R�R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_table_names�	s			*cKs�|jd	krt�n|dkr0|j}n|jd
krO|j||�S|j}|jd|jj|��}g|j	|d|�D] }|ddkr�|d^q�S(NiiisSHOW FULL TABLES FROM %sR3itVIEWsSYSTEM VIEW(iii(iii(R�sSYSTEM VIEW(
R�R[RvR�R�R�R�R�RtR�(RTR�R)RdR3R�R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_view_names�	s		cKs|j||||�}|jS(N(t_parsed_state_or_createt
table_options(RTR�R�R)Rdtparsed_state((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_table_options�	scKs|j||||�}|jS(N(R�R(RTR�R�R)RdR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_columns�	sc	Ks�|j||||�}xT|jD]I}|ddkr"g|dD]}|d^qC}i|d6dd6Sq"Wigd6dd6S(NRwtPRIMARYRitconstrained_columnsR�(R�R�Rv(	RTR�R�R)RdR�R�tsR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_pk_constraint�	s!cKsX|j||||�}d}g}x|jD]}|dd}	t|d�dkrf|ddpi|}
|
s�|dkr�|jj}n||kr�|}
q�n|d}|d}i}
x1dD])}|j|t�r�|||
|<q�q�Wi|d	d	6|d
6|
d6|	d6|d
6|
d6}|j|�q.W|j	rT|j
||�n|S(NR�i����ii����tlocalR}tonupdatetondeleteR�R�treferred_schematreferred_tabletreferred_columnstoptions(R�R�(R�Rvtfk_constraintsR�RWR�R RyR�R�t_correct_for_mysql_bug_88718(RTR�R�R)RdR�tdefault_schematfkeysR/tref_namet
ref_schemat	loc_namest	ref_namestcon_kwRtfkey_d((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_foreign_keys�	s:*



	cCsl|jdkrd�}n	d�}|jj}g|D]@}|dD]/}||dp[|�||d�|f^qEq7}|rh|jtjd�jtjd	d
t��d	|�}t	t
�}	x=|D]5\}
}}||	||
�||�f|j�<q�Wx`|D]U}
g|
dD]:}|	||
dp6|�||
d�f|j�^q|
d<qWndS(NiicSs
|j�S(N(tlower(R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR	
scSs|S(N((R�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR	
sR�R�R�s�
                    select table_schema, table_name, column_name
                    from information_schema.columns
                    where (table_schema, table_name, lower(column_name)) in
                    :table_data;
                t
table_datat	expanding(ii(t_casingRWR�R�R*RNt
bindparamst	bindparamR�RR�R	(RTRR�R	R�trectcol_namet
col_tuplestcorrect_for_wrong_fk_casetdR)ttnametcnametfkeyRl((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�
s&
	
@		
*
cKsH|j||||�}g|jD]"}i|dd6|dd6^q"S(NR�tsqltext(R�tck_constraints(RTR�R�R)RdR�R/((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_check_constraintsM
scKs2|j||||�}i|jjdd�d6S(Nt
mysql_commentRN(R�R�R Rv(RTR�R�R)RdR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_table_commentX
sc
Ks?|j||||�}g}x|jD]}i}t}	|d}
|
dkrVq(n|
dkrkt}	n;|
dkr�|
|d<n"|
dkr�n|jjd|
�|dr�|d|d	<ni}|r�||d
<n|d|d<g|dD]}|d
^q�|d<|	|d<|
r*|
|d<n|j|�q(W|S(NRwR�tUNIQUEtFULLTEXTtSPATIALR
s-Converting unknown KEY type %s to a plain KEYRtmysql_with_parserRR�Ritcolumn_namesR�(RR(R�R�RyR�RvtloggertinfoR�(
RTR�R�R)RdR�tindexesR/RR�tflavortindex_dR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_indexes_
s:
	
	


%

cKsz|j||||�}g|jD]T}|ddkr"i|dd6g|dD]}|d^qQd6|dd6^q"S(NRwRR�RiR tduplicates_index(R�R�(RTR�R�R)RdR�R�Rl((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_unique_constraints�
s

cKsF|j}dj|jj||��}|j|d|d|�}|S(NR�R�(R�R�R�Rwt_show_create_tableRv(RTR�t	view_nameR)RdR3R�R*((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pytget_view_definition�
s	cKs%|j|||d|jdd��S(Nt
info_cache(t
_setup_parserR Rv(RTR�R�R)Rd((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��
s
cCsI|jdkr0|jr0|j|dt�}n	|j}tj||�S(s�return the MySQLTableDefinitionParser, generate if needed.

        The deferred creation ensures that the dialect has
        retrieved server version information first.

        iiRr(ii(R�R�RRyR�RtMySQLTableDefinitionParser(RTR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_tabledef_parser�
s	c
Ks�|j}|j}dj|jj||��}|j|d|d|�}tjd|�r�|j	|d|d|�}	|j
||	�}n|j||�S(NR�R�s^CREATE (?:ALGORITHM)?.* VIEW(R�R/R�R�RwR)RvR�R�t_describe_tablet_describe_to_createtparse(
RTR�R�R)RdR3RR�R*R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR-�
s			cCs
t��dS(N(R[(RTR�((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��
scCs�|j}|j|jd�d|�}|s6d}nB|ddkrOd}n)|ddkrhd}nt|d�}||_|S(s�Sniff out identifier case sensitivity.

        Cached per-connection. This value can not change without a server
        restart.

        s,SHOW VARIABLES LIKE 'lower_case_table_names'R3iitOFFtON(R�R�R�R�R(RTR�R3R@tcs((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR��
s							cCsci}|jdkrnG|j}|jd�}x,|j||�D]}|d||d<qCW|S(sYPull the active COLLATIONS list from the server.

        Cached per-connection.
        iiisSHOW COLLATION(iii(R�R�R�R�(RTR�t
collationsR3R�R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt_detect_collations�
s	cCsW|j|jd�d|j�}|s@tjd�d|_n|dpMd|_dS(NsSHOW VARIABLES LIKE 'sql_mode'R3s[Could not retrieve SQL_MODE; please ensure the MySQL user has permissions to SHOW VARIABLESR�i(R�R�R�R,R�t	_sql_mode(RTR�R@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�scCsq|j}|sd}n7|j�rOt|�}|dB|krFdpId}nd|k|_d|k|_dS(s/Detect and adjust for the ANSI_QUOTES sql mode.R�itANSI_QUOTEStNO_BACKSLASH_ESCAPESN(R8tisdigitR�R�R�(RTR�tmodetmode_no((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�s		c	Cs�|dkr!|jj|�}nd|}d}y|jdt�j|�}WnCtjk
r�}|j|j	�dkr�tj
|��q��nX|j|d|�}|s�tj
|��n|dj�S(s&Run SHOW CREATE TABLE for a ``Table``.sSHOW CREATE TABLE %sR�izR3iN(RvR�RR�R�R�R'R�R�R�tNoSuchTableErrorR�tstripR*(	RTR�R�R3R�R�R�RfR@((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR)!s"
		
c
Cs�|dkr!|jj|�}nd|}d\}}z�y|jdt�j|�}Wnqtjk
r�}|j|j	�}	|	dkr�tj
|��q�|	dkr�tjd||f��q��nX|j|d|�}Wd|r�|j
�nX|S(	s7Run DESCRIBE for a ``Table`` and return processed rows.sDESCRIBE %sR�iziLs1Table or view named %s could not be reflected: %sR3N(NN(RvR�RR�R�R�R'R�R�R�R>tUnreflectableTableErrorR�R�(
RTR�R�R3R�R�R�RARftcode((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR0;s,
		
N(`R]R^t__doc__R�R�tsupports_alterRytsupports_native_booleantmax_identifier_lengthtmax_index_name_lengthtsupports_native_enumtsupports_sane_rowcounttsupports_sane_multi_rowcounttsupports_multivalues_inserttsupports_commentstinline_commentstdefault_paramstyletcolspecstcte_follows_insertR_tstatement_compilerR�tddl_compilerR-R�t
ischema_namesRlRR�R�RtTableRvR*tUpdateR!tIndextconstruct_argumentsRqR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tpropertyR$R�R�R�R�RtcacheR�R�R�R�R�R�RR�RRR&R(R+R�R,tmemoized_propertyR/R-R�R�R7R�R�R)R0(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRzs�		
											

		#		*	J
)						R�cBsReZdZidd6dd6dd6dd6d	d
6Zd�Zd�Zd
�ZRS(s�Return 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.

    tkoi8_rtkoi8rtkoi8_utkoi8us	utf-16-betutf16tutf8tutf8mb4tujisteucjpmscCs%||_|jj||�|_dS(N(trowproxyt_encoding_compatR R3(RTRcR3((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyRqos	cCs^|j|}t|t�r+|j�}n|jrVt|tj�rV|j|j�S|SdS(N(RcRzt_arrayttostringR3R,tbinary_typeR�(RTR�titem((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt__getitem__ss
cCsct|j|�}t|t�r0|j�}n|jr[t|tj�r[|j|j�S|SdS(N(	R�RcRzReRfR3R,RgR�(RTR2Rh((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt__getattr__}s(R]R^RBRdRqRiRj(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyR�Zs
		
(}RBRRetcollectionsRR�R�R�RRt
enumeratedRRRKRRRR+RR	R
RRR
RRRRRRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)RR*R�R,tengineR-R.R/R0R1R2R3R4R5R�RxR�tIR7RStSET_REtMSTimetMSSettMSEnumt
MSLongBlobtMSMediumBlobt
MSTinyBlobtMSBlobtMSBinarytMSVarBinarytMSNChart
MSNVarChartMSChartMSStringt
MSLongTexttMSMediumTextt
MSTinyTexttMSTexttMSYeartMSTimeStamptMSBittMSSmallIntegert
MSTinyIntegertMSMediumIntegertMSBigIntegert	MSNumerict	MSDecimaltMSDoubletMSRealtMSFloatt	MSIntegertNumerictFloatR�tEnumt	MatchTypeRNRRtDefaultExecutionContextRRR�R_tDDLCompilerR�tGenericTypeCompilerR-tIdentifierPreparerRltclass_loggerR�RztobjectR�(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.pyt<module>�sf







�,��3	���?

Zerion Mini Shell 1.0