[sqlalchemy] Setting the starting value of an autoincrement field?
Is there a way in the standard SQLA dialect support to set the starting value of an autoincrement field in the SQLA table definition? I can't see anything in the docs or code, but something like this is what I'm thinking: empnum = Column(sqla.Integer, primary_key = True, autoincrement = True, autoincrementstart = 1) which would make the first record have an empnum of 1 instead of 1. I'm learning that the autoincrement support across databases is a bit odd (what's up with Oracle??) and I expect if I want to do this I'll need to do some manual work, but figured I'd ask first. If no way to set the start at table definition time, what about a clean way to change the current value just after definition? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Setting the starting value of an autoincrement field?
On Sep 20, 2010, at 11:00 PM, Russell Warren wrote: Is there a way in the standard SQLA dialect support to set the starting value of an autoincrement field in the SQLA table definition? I can't see anything in the docs or code, but something like this is what I'm thinking: empnum = Column(sqla.Integer, primary_key = True, autoincrement = True, autoincrementstart = 1) Look at class sqlalchemy.schema.Sequence(name, start=None, increment=None,...) http://www.sqlalchemy.org/docs/core/schema.html?highlight=sequence#sqlalchemy.schema.Sequence Table('sometable', metadata, Column('id', Integer, Sequence('some_id_seq'), primary_key=True) ) http://www.sqlalchemy.org/docs/dialects/postgresql.html?highlight=sequence Cheers, M -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.