]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Docs.
authorJason Kirtland <jek@discorporate.us>
Sun, 12 Aug 2007 04:51:21 +0000 (04:51 +0000)
committerJason Kirtland <jek@discorporate.us>
Sun, 12 Aug 2007 04:51:21 +0000 (04:51 +0000)
lib/sqlalchemy/databases/mysql.py

index 2d9c3af4c34e2defbda92bf06755ea63f5c0abf0..5aebac09bfa09de94d0a7e21ae406fa233f0bab5 100644 (file)
@@ -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