Hi Simon,
On Fri, 21 Aug 2009, King Simon-NFHD78 wrote:
> Faheem Mitha wrote:
>> 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.
> The sequence isn't directly related to the table (as far as I'm aware).
> Instead, when you insert a row into the table, you do something like
> "SELECT NEXTVAL('<sequencename>')" to get the next ID value. SQLALchemy
> does this automatically for you.
Ah, so that is something I would have to do manually if working with pg
more directly? Nice of sqla to do it for me.
>> I'm still puzzled why sqlalchemy lists the entries in the table, when
>> querying directly via psql doesn't show it.
>>
>
> Your SQLAlchemy operations are happening within a transaction that never
> gets committed. If you turned on SQL echoing (use echo=True or
> echo='debug' in your call to create_engine), you would see that your
> object is actually being inserted into the 'mytest' table. When you
> SELECT from the table, you are still in the same transaction, so you see
> the rows that you have inserted.
>
> However, when the script exits, the transaction gets rolled back, so you
> never see the new rows in psql. The only evidence that anything ever
> happened is that the sequence has moved on (see the note at the bottom
> of http://www.postgresql.org/docs/8.1/static/functions-sequence.html)
Thanks, that's a very clear and educational explanation. So mytest
contains this sequence, but is not written to disk.
Regards, Faheem.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---