On Fri, 21 Aug 2009, King Simon-NFHD78 wrote:
> I've never used postgres, but I believe auto-incrementing counters are
> implemented using database sequences. I think these are incremented
> outside of a transaction - this ensures that two seperate database
> connections using the sequence at the same time will get distinct
> values. So although you aren't commiting your transaction, the sequence
> still advances.
>
> I guess the sequence must be associated with the table, so when you drop
> the table it destroys the sequence as well (I don't know if this is SA
> behaviour or PG behaviour).
>
> session.dirty only contains objects that have been loaded from the DB
> and subsequently modified. You don't ever actually modify your object,
> so it shouldn't appear in session.dirty. (It should appear in
> session.new though)
>
> Hope that helps,
>
> Simon
Hi Simon,
Thanks for the fast and helpful response. This looks like an artifact of
how I am creating the table. I wonder if this would still show up if I
explicitly specified the id. I could check this. Also, presumably if I had
other cols in the table, they wouldn't show up in sqla's printout.
There is a discussion of this in
http://neilconway.org/docs/sequences/
Quote:
"A sequence is a special kind of database object designed for generating
unique numeric identifiers. It is typically used to generate artificial
primary keys."
I'm still puzzled why sqlalchemy lists the entries in the table, when
querying directly via psql doesn't show it.
Regards, Faheem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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
-~----------~----~----~----~------~----~------~--~---