yes, you should, and your commented-out code looks fine
On 1/20/07, jose <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I have a question about transactions....
> I need to insert data into two tables (anag and user), sice I need to
> insert the generated primary key of anag into user.
> I have to flush anag to have the id to insert into user table.
> What happens if there's an interruption in the middle of this, for
> example, immediately after to flush anag?
> Should I use create_transaction() to avoid a such thing?
>
> #transaction = session.create_transaction()
> #try:
> anag = Anag(
> name = data.get('display_name')
> )
> session.save(anag)
> session.flush()
>
> user = User(
> anag_id = anag.id
> )
> session.save(user)
> session.flush()
>
> #transaction.commit()
> #except:
> #transaction.rollback()
>
> jo
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---