sagblmi wrote:
>
> When looking for the session status I've
> session.is_active == True
> When checking the log file I don't have 'commit ' between working and
> failing code. I don't know if it's normal but I've a strange behaviour
> with session.query().get()
> For the same Class and Id, If I call X times session.query.get() in
> one case SA issue an SQL query for each call and in an other case SA
> issue an SQL query only on the first call....

this is all by design.   get() returns the object from the Session if
already present. If the object is expired, it does a SELECT to make sure
the object is still alive in the DB.   the two cases where expiration
occurs automatically are documented - after commit() and after rollback().

its best if your application doesn't establish any dependency on any of
this, i.e. you work with the Session, it queries the DB as needed.   if
you're working with objects that have become detached, merge() them back
into the current session so they can once again query their state from the
database as needed.   If it turns out that too many queries are being
issued and performance is suffering, there's ways to address that too, but
you should start out by not worrying about any of that.


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

Reply via email to