On Nov 22, 2008, at 4:47 PM, Hinrich Winther wrote:

>
> Hi,
>
> How do I something like
> myObject = session1.query(something).one()
> session2.add(myObject)
>
> without the need to expunge myObject from session1?

use session.merge()

> and another one:
> How can I compare objects from different sessions to see if they
> origin from the same row in the db?

you'd want to compare the values of their primary key attributes.     
If you want a generic way without knowing what those attributes are,  
there's ways to determine them from the mappings, but it might be  
eaiser to compare their "key":

from sqlalchemy.orm.attributes import instance_state
instance_state(x1).key == instance_state(x2).key

note that "key" is None for a transient/pending object.



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