Mike Conley wrote:
> Does the idea of last_inserted_ids exist for ORM?
>
> I do
>       session.add(someobj)
>       session.commit()
> and then want the id of the newly inserted object.
>
> I can reference
>       someobj.id
> but this generates a select call to the database

get the id before you call commit().   the same thing would apply with SQL
expressions, as the cursor is gone when the transaction is closed.   you
can call session.flush() to force a flush.

alternatively, set "expire_on_commit=False" on your Session.



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to