9 messages in com.googlegroups.sqlalchemy[sqlalchemy] sequence-related question| From | Sent On | Attachments |
|---|---|---|
| Eric Lemoine | 30 Apr 2008 09:56 | |
| Michael Bayer | 30 Apr 2008 12:02 | |
| Eric Lemoine | 30 Apr 2008 12:22 | |
| Eric Lemoine | 30 Apr 2008 12:25 | |
| Michael Bayer | 30 Apr 2008 12:44 | |
| Eric Lemoine | 30 Apr 2008 12:45 | |
| Eric Lemoine | 30 Apr 2008 13:08 | |
| Michael Bayer | 30 Apr 2008 13:08 | |
| Eric Lemoine | 02 May 2008 09:17 |
| Subject: | [sqlalchemy] sequence-related question![]() |
|---|---|
| From: | Eric Lemoine (eric...@gmail.com) |
| Date: | 04/30/2008 09:56:06 AM |
| List: | com.googlegroups.sqlalchemy |
Hello
I insert a new line in a table using this:
campfacility = Campfacility(prop1, prop2) model.Session.save(campfacility) model.Session.commit()
The campfacility id is handled by a postgres sequence.
What I'd like to do is:
campfacility = Campfacility(prop1, prop2) seq = Sequence('some_sequence') model.Session.execute(seq) model.Session.save(campfacility) model.Session.commit()
to know before inserting the line what id it will get. The above code doesn't seem thread-safe to me:
thread 1 thread 2 execute(seq) -> nextid = n
execute(seq) -> nextid = n model.Session.save(campfacility)
model.Session.save(campfacility) -> BUG, nextid isn't correct
I'm sure there's a way to make this thread-safe but right now I just don't know how.
Can someone help?
Thanks a lot,
PS: I just love SA ;-)
-- Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




