# -*- fill-column: 78 -*-
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Michael Bayer email@example.com
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Support for the MySQL database.
-For normal SQLAlchemy usage, importing this module is unnecessary. It will be
-loaded on-demand when a MySQL connection is needed. The generic column types
-like :class:`~sqlalchemy.String` and :class:`~sqlalchemy.Integer` will
-automatically be adapted to the optimal matching MySQL column type.
-But if you would like to use one of the MySQL-specific or enhanced column
-types when creating tables with your :class:`~sqlalchemy.Table` definitions,
-then you will need to import them from this module::
- from sqlalchemy.dialect.mysql import base as mysql
- Table('mytable', metadata,
- Column('id', Integer, primary_key=True),
- Column('ittybittyblob', mysql.TINYBLOB),
- Column('biggy', mysql.BIGINT(unsigned=True)))
-All standard MySQL column types are supported. The OpenGIS types are
-available for use via table reflection but have no special support or mapping
-to Python classes. If you're using these types and have opinions about how
-OpenGIS can be smartly integrated into SQLAlchemy please join the mailing
Supported Versions and Features
SQL features- if your server version does not support sub-selects, for
example, they won't work in SQLAlchemy either.
-Currently, the only DB-API driver supported is `MySQL-Python` (also referred to
-as `MySQLdb`). Either 1.2.1 or 1.2.2 are recommended. The alpha, beta and
-gamma releases of 1.2.1 and 1.2.2 should be avoided. Support for Jython and
+Most available DBAPI drivers are supported; see below.
See the official MySQL documentation for detailed information about features
supported in any given server release.
+See the API documentation on individual drivers for details on connecting.
+All of MySQL's standard types are supported. These can also be specified within
+table metadata, for the purpose of issuing CREATE TABLE statements
+which include MySQL-specific extensions. The types are available
+from the module, as in::
+ from sqlalchemy.dialects import mysql
+ Table('mytable', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('ittybittyblob', mysql.TINYBLOB),
+ Column('biggy', mysql.BIGINT(unsigned=True)))
+See the API documentation on specific column types for further details.
+MySQL features an automatic connection close behavior, for connections that have
+been idle for eight hours or more. To circumvent having this issue, use the
+``pool_recycle`` option which controls the maximum age of any connection::
+ engine = create_engine('mysql+mysqldb://...', pool_recycle=3600)
Some limited direct support for MySQL extensions to SQL is currently
- select(..., prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
- update(..., mysql_limit=10)
-MySQL's BOOL type is a synonym for SMALLINT, so is actually a numeric value,
-and additionally MySQL doesn't support CHECK constraints. Therefore SQLA's
-Boolean type cannot fully constrain values to just "True" and "False" the way it does for most other backends.
+ select(..., prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
+ update(..., mysql_limit=10)