From 685f281d4047e4f4ce13d8ff7f7f80923f0d945d Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Sun, 12 Aug 2007 04:51:21 +0000 Subject: Docs. --- lib/sqlalchemy/databases/mysql.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/sqlalchemy/databases/mysql.py') 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 -- cgit v1.2.1