On Feb 11, 2008, at 9:52 AM, maxi wrote:

>
> Hi,
> I've a problem, aparently, with refresh data in a user concurrent
> system using orm lib.
> For instance, an user do a query request which return a objects list.
>
> people = session.query(Person).filter_by().all()
>
> and, I show this in my GUI (a gtk.treeview)
>
> Now, another user, on your workstation change some values for a person
> object.
> When, the first user, re-query for get the new values, using
>
>   people = session.query(Person).filter_by().all()
>
> New values aren't returned.
>
> How can refresh to get the new changed values?
>
> Thanks in advance.
>
> P.D.: I'am using sa 0.3.10


The easiest in this case is to use query.populate_existing():

sess.query(Person).populate_existing().filter_by().all()

however, this method is only available in 0.4.

in 0.3, several options:

1. clear the session, then query:

sess.clear()
sess.query(Person)....

2. expire the individual objects you'd like refreshed

sess.expire(person1)
sess.expire(person2)
sess.query(Person)....

3. just refresh the objects you'd like refreshed

sess.refresh(person1)
sess.refresh(person2)





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