[Zope-DB] MySQL ZSQL Transactions or Commit in Zope?

2005-05-17 Thread Itziar Aldabe
Hello,
we have a similar problem. We want to access two databases each of them 
with its corresponding
Z MySql Database connection. We want to:

1- Insert record A into ERREUS database
2- Get auto_increment id for record A
3- Insert record B into IRAKAZI database with auto_increment id.
when we execute steps 1 and 2 within a python script, it's correct.
when we execute steps 2 and 3 within a python script, it's correct.
but, if we want to execute all the steps together we receive this message:
*Error Type: OperationalError*
*Error Value: (1205, 'Lock wait timeout exceeded; Try restarting 
transaction')*

Can someone help us, please?
Thanks!
Itziar
Message: 1
Date: Sun, 15 May 2005 16:30:38 -0400
From: Michael Schwartz [EMAIL PROTECTED]
Subject: [Zope-DB] MySQL ZSQL Transactions or Commit in Zope?
To: zope-db@zope.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii
I am trying to find sample code for performing transactions in ZSQL with
mysql 4.1.  I'd like to do something like this:
1 - Insert record A into USER table
2 - Get auto_increment id for record A
3 - Insert record B into WIDGET table with auto_increment id from
previous step
But if step 3 fails, I want to undo step 1. 

Do I need to back out manually?
Thanks in advance! 

Mike Schwartz

 

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] MySQL ZSQL Transactions or Commit in Zope?

2005-05-17 Thread Dieter Maurer
Michael Schwartz wrote at 2005-5-15 16:30 -0400:
I am trying to find sample code for performing transactions in ZSQL with
mysql 4.1.  I'd like to do something like this:
 
1 - Insert record A into USER table
2 - Get auto_increment id for record A
3 - Insert record B into WIDGET table with auto_increment id from
previous step

But if step 3 fails, I want to undo step 1. 

Provided you use transactional tables (i.e. you use MySQL
in a way that it support transactions), then you only
need to abort the Zope transaction (which happens automatically
when an exception reached ZPublisher).

-- 
Dieter
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db