Hi,

I just want to check on something. Let's say I've got a script that's 
populating a database and will commit the transaction at the end. It looks for 
a particular object (let's call it "A"), and if NoResultFound it creates a new 
object and does a session.add(A).

What if in a later iteration the script (before commit), I look up A again. The 
query seems to not find the object in the database (of course), but not the 
session either. The 'solution' is to keep track of new objects of that type I 
create and look in that list before attempting to create a new one. This 
doesn't seem elegant. Ideally I would have thought that a session.query()... 
would have found the object newly added into the session. Am I missing 
something or is there a more elegant way to handle this?

In this case, I'm ok creating a nested session and saving the object directly 
to the database so it's available for future queries. What's the best practice 
method to do this?

Cheers,
Demitri

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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