[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
Thank you much! You hit the nail on the head with your observation about the bldcmdid not being a primary key. I verified that an identical operation worked 100% correctly on a table where the primary key was also a serial type. I needed the combination of a few keys to be unique. I naively used

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Michael Bayer
just take the object instance that was just flushed() and pull the primary key from the attributes of the object itself. such as instance.bldcmdid, if thats the attribute you want. as for your double primary key problem, id have to see what youre doing (i.e. whos creating the tables, you or SA ?

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
I don't need to do anything between. Our use of transactions is simple-- almost always a single-operation happens per flush. I looked at after_insert, but am not exactly sure how that can help me. Do I need to define something so that it retrieves the record from the database? (I looked for docu

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Michael Bayer
if youre using the ORM, its doing a flush() which can insert many values at once. the ID for each value is available on the newly saved instance directly. if you need to get the ID at the instant its saved, you can implement the after_insert() method on mapper extension which will give you the i

[sqlalchemy] Re: sequences skipping and reporting incorrectly

2006-12-01 Thread Rick S.
>From the postgresql documentation: CREATE TABLE tablename ( colname SERIAL ); is equivalent to specifying: CREATE SEQUENCE tablename_colname_seq; CREATE TABLE tablename ( colname integer DEFAULT nextval('tablename_colname_seq') NOT NULL ); And, postgresql regarding default values: