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 sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to