You need to create a single file Python script, which creates a 
CoverBatchStackItem class with just two columns - "id" and "qty".    Then, it 
inserts one row into a local sqlite database, then loads, updates qty in the 
manner in which you describe, and commits.   Use the examples in the object 
relational tutorial as a guide to conventions.  When that works as expected,  
that is the test case you start with.   If it does not work as expected, send 
it to me and I can tell you what's wrong with it.    But assuming it works, the 
job is then to slowly work along each element of your actual application to 
determine what about your app is different from the working specimen.   Add new 
elements to your specimen corresponding to your application one at a time, to 
determine the trigger that causes the problem.

This is a very pedantic way of going about things, but the excerpts you've 
given me are extremely simple and no such issue should be occurring.   So the 
issue most likely lies within subtle artifacts of your actual code.




On Mar 17, 2011, at 10:20 AM, writeson wrote:

> Michael,
> 
> I tried creating a simple standalone example using our data, but the
> table relations complexity would make the example fairly huge. So
> unfortunately that means I didn't get one working.
> 
> In my Pylons applications the sequence of events are as follows:
> 
> get a session
> create a new item
> add the item to the session
> session commit
> // sometime later
> get a session
> get an item from the session with a query
> modify the qty value of the item
> session commit
> 
> I have resolved the issue by hacking my code to do the following:
> 
> session = Session()
> session.query(CoverBatchStackItem) \
> .filter((CoverBatchStackItem.cover_batch_id==cover_batch_id) and
> (CoverBatchStackItem.order_id==foid)) \
> .update({CoverBatchStackItem.qty: qty})
> session.commit()
> 
> where qty is passed into the method that executes this code. Here I'm
> querying for the item and updating it in one long statement. This
> works but looks ugly compared to the original code.
> 
> Thanks!
> Doug
> 
> -- 
> 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.
> 

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

Reply via email to