Thanks for the the advice Domen, that seems to clear up many of my problems :-)

So right now I'm able to create a session, pull a few thousand records
and then close that session.  Then those instances get displayed in
the gui and might get changed by some other threads, which will commit
them back using a new session.

Is that the proper usage of sqlalchemy?


2009/3/30 Domen Kožar <[email protected]>:
>
> You may want to take a look at expire_on_commit:
> http://www.sqlalchemy.org/docs/05/reference/orm/sessions.html?highlight=sessionmaker#sqlalchemy.orm.sessionmaker
>
> On Mar 30, 1:30 am, Christiaan Putter <[email protected]> wrote:
>> Hi guys,
>>
>> I haven't been able to figure out how to work with sessions, threads
>> and a gui yet?  Can someone explain to me what the best practices are?
>>
>> The main problem really is that for displaying data on a gui I need an
>> open session the entire time.  It seems as soon as I close a session
>> instance attributes become expired and are removed from the state
>> (this depends on prior commits, refreshes etc. though) and the rest of
>> my app looses access to that info.
>>
>> I'm using postgres which doesn't allow any active connections during
>> table creation or removal, and I do a lot of that while my app is
>> running.  So that complicates the whole permanently active session for
>> the gui idea.
>>
>> Also, if instances are attached to some session just for them to be
>> displayed on the gui it makes it hard for background threads to alter
>> their state and commit that back to the database.
>>
>> I'm sure this is quite trivial, but I haven't been able to figure out
>> the best way to go about this yet.
>>
>> Any advice?
>>
>> Regards,
>> Christian
> >
>

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