[sqlalchemy] Re: An instance's attributes lost while the other updated.

2009-02-26 Thread Michael Bayer

commit() by default expires all the attributes on all instances. 
See the documentation on Using the Session for details about this.

Also a single Session should never be accessed by concurrent threads,  
referring to the previous email where you got a SQLite error regarding  
concurrency.


On Feb 26, 2009, at 2:36 AM, 一首诗 wrote:


 A little more code to explain:

 Before commit, print u2 doesn't do trigger query.
 After commit, print u2 trigger a query, even if it has different
 primary key with u1.

 So this means : when u update one instance, the other instance of the
 same type will be in expired state.

 ##
u1 = session.merge(u1)

print --
print u2

session.commit()

print --
print us
 ##

 On Feb 26, 2:17 pm, 一首诗 newpt...@gmail.com wrote:
 Hi all,

 I have 2 user instance in a session and after I have update one of it
 like this

 --- 
 

 u = session.merge(u)
 session.commit
 session.refresh(u)

 --- 
 

 Later, I found that another instance of the same class type in the
 session's attributes was cleared, and triggered a database query.

 (I found this because I am using sqlite, which forbids access the  
 same
 database in more than one thread)

 I will make some debug to find out what happened.
 


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: An instance's attributes lost while the other updated.

2009-02-25 Thread 一首诗

A little more code to explain:

Before commit, print u2 doesn't do trigger query.
After commit, print u2 trigger a query, even if it has different
primary key with u1.

So this means : when u update one instance, the other instance of the
same type will be in expired state.

##
u1 = session.merge(u1)

print --
print u2

session.commit()

print --
print us
##

On Feb 26, 2:17 pm, 一首诗 newpt...@gmail.com wrote:
 Hi all,

 I have 2 user instance in a session and after I have update one of it
 like this

 --- 
 

 u = session.merge(u)
 session.commit
 session.refresh(u)

 --- 
 

 Later, I found that another instance of the same class type in the
 session's attributes was cleared, and triggered a database query.

 (I found this because I am using sqlite, which forbids access the same
 database in more than one thread)

 I will make some debug to find out what happened.
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---