From: Jason Kirtland Date: Sun, 12 Aug 2007 04:51:21 +0000 (+0000) Subject: Docs. X-Git-Tag: rel_0_4beta1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=685f281d4047e4f4ce13d8ff7f7f80923f0d945d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Docs. --- diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 2d9c3af4c3..5aebac09bf 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