>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:
"A column can be assigned a default value. When a new row is created
and no values are specified for some of the columns, the columns will
be filled with their respective default values."
------
So, looking at the SQL statement emitted:
INSERT INTO build_commands
(cmdname, cmdvers, argtemplate) VALUES (%(cmdname)s, %(cmdvers)s,
%(argtemplate)s)
It seems that the omission of the bldcmdid field triggered an execution
of nextval(). This would explain the skipped numbers. Still not sure
about retrieving the incorrect number, though.
---
By the way, what I really want to do is find the ID for the record I
just inserted. I need to create entries in a different table that uses
bldcmdid as a foreign key. I will use the bldcmdid of the recently
created record as column data in my other table.
I did find a reference to using a result proxy in this newsgroup in
order to get the last transaction info. However, this applied to more
direct sql manipulations. I am using ORM and am not aware of a way to
find out what the last-saved record is. I did not see anything when
poking around in the engine or session objects. (Maybe I did not dig
deep enough?)
Rick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---