Questions on SQLAlchemy objects bound to database sessions

0 views
Skip to first unread message

DD

unread,
Jan 6, 2010, 9:23:36 PM1/6/10
to pylons-...@googlegroups.com
Hi,
Is there a way to use SQLAlchemy such that the objects stay as far from
the session as possible? I am not using lazy loading, cascade features
or any of those functions that might warrant this.

Basically, what I want to do is, once I get an object out of the
database, that object should not know anything about the database or
rely on the session.

Also, I want to serialize this object to a file and deserialize/load it
later without bothering with the database. Everything I will ever need
is already populated in the object.


I am sorry if this is something very trivial, but I am not able to
figure out the right way to do it. The documentation that I came across
discusses on how to detach an object from the session, and then how to
re-attach it later. Ideally, I would not want to reattach it to the
session, but just use it like a regular object.

Any suggestions on how to do this correctly?

Thanks,
DD.

Brian O'Connor

unread,
Jan 6, 2010, 11:13:19 PM1/6/10
to pylons-...@googlegroups.com
I think you're looking for expunge().

Hope that helps

--
Sent from my mobile device

Brian O'Connor

Reply all
Reply to author
Forward
0 new messages