I have ORM mapped tables with a schema like the following:
---
Table 'users':
  user_id integer
  username text
  balance integer

Table 'products':
  product_id integer
  cost integer

Table 'user_products':
  user_id integer
  product_id integer
---

when a user buys a product, I need to add a user_product record for
them, and deduct the cost of the product from the user's balance. I
need to do the latter in an atomic fashion, however (eg, "UPDATE users
SET balance = balance - ? WHERE user_id = ?") in the same transaction
as the ORM changes to create the user_products record. Ideally, I need
to update the relevant User object with the updated balance, too.

Can anyone provide me with a quick overview of how to do this?

Thanks,

Nick Johnson


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to