how to set the initial value for auto_increment?

671 views
Skip to first unread message

Phoebe pei

unread,
Apr 18, 2012, 11:27:22 PM4/18/12
to sqlal...@googlegroups.com
class MyMode(Base):
__tablename__ = 'mymodel'
__table_args__ = ({
'sqlite_autoincrement' : True,
})

id = Column(Integer, primary_key=True)

def __init__(self, id):
self.id = id

How can I set the initial value for the id column?

Michael Bayer

unread,
Apr 19, 2012, 10:16:00 AM4/19/12
to sqlal...@googlegroups.com
SQLite doesn't support an initial value for auto-incrementing fields.   It has two flavors of autoincrement, the ROWID and AUTOINCREMENT versions.  By setting sqlite_autoincrement it means you're choosing AUTOINCREMENT.      But neither support a way to set the initial value, see http://sqlite.org/lang_createtable.html and http://sqlite.org/autoinc.html.




--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/j2DcE3bYYIIJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply all
Reply to author
Forward
0 new messages