> BEGIN;
> INSERT INTO account (id, name, balance) VALUES (100, 'John Doe', 100.0);
> INSERT INTO account (id, name, balance) VALUES (150, 'Jane Doe', 10.0);
> INSERT INTO new_accounts (account_id, start_balance) VALUES
>        ((SELECT id FROM account WHERE name = 'John Doe'),
>         (SELECT balance FROM account WHERE name = 'John Doe'));
> INSERT INTO new_accounts (account_id, start_balance) VALUES
>        ((SELECT id FROM account WHERE name = 'Jane Doe'),
>         (SELECT balance FROM account WHERE name = 'Jane Doe'));
> COMMIT;

If you translate it to sqlalchemy, it will be something like:

transaction = session.create_transaction()
a1 = Account(...)
a.flush() # Flush does not commit, it only inserts
a2 = Account(...)
a2.flush()
transaction.commit()

And, if you write it in a turbogears controller, you can omit the
transaction statements, as it is built-in (by turbogears)

sanjay


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to