diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-12 04:51:21 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-12 04:51:21 +0000 |
commit | 685f281d4047e4f4ce13d8ff7f7f80923f0d945d (patch) | |
tree | c6ecdbbce7375ca5c1cf911dca8d1a97496fae27 /lib/sqlalchemy/databases/mysql.py | |
parent | 138eee02f58cd363716d709e27cedc76df0faf9a (diff) | |
download | sqlalchemy-685f281d4047e4f4ce13d8ff7f7f80923f0d945d.tar.gz |
Docs.
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 2d9c3af4c..5aebac09b 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -62,6 +62,25 @@ time:: Table('mytable', metadata, autoload=True, ForeignKeyConstraint(['other_id'], ['othertable.other_id'])) +When creating tables, SQLAlchemy will automatically set AUTO_INCREMENT on an +integer primary key column:: + + >>> 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 supplying ``autoincrement=False`` in addition. +This 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 SQL modes are supported. Modes that enable ``ANSI_QUOTE`` (such as ``ANSI``) require an engine option to modify SQLAlchemy's quoting style. When using an ANSI-quoting mode, supply ``use_ansiquotes=True`` when |