Are you sure it doesn't do it out of the box?
I know it does for ZPsycopgDA which is the Postgresq Zope database adapter.
With that one I don't have to come near handling the SQL transactions. What Zope commits and rollsback is done for SQL too automatically.

robert rottermann wrote:
Hi there,

I am implementing a tool to handle userdata that is stored in a MySQL db.
The underlaying logic of the stored procedures used to maintain the db
dictate that I have to control the transactions myself.
I understand that there is a way to handle transaction controll in the
methods. However I find no documentation at all on how to use it.

Without using ZMySQL methods I would be using the following piece of code:
db = mysql.connect(host="localhost" ...)
cursor = db.cursor()
query = "CALL insertUser('%s', '$xxx$', @id, @error);select @id, @error"
% 'JohnTheUser'
# get the next resultset, it has the result of the select
result = cursor.fetchall()[0]
error = int(result[1])
if error:
    print "error %s when trying to add user %s" % (ERRRORS[error],
    continue #we are in a loop actually

How can I mimic that using ZSQL Methods

thanks for any pointers

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Peter Bengtsson,
Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to