[Zope] ZSQL Methods and transaction control

robert rottermann robert at redcor.ch
Wed Jan 10 03:00:06 EST 2007


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
content
dictate that I have to control the transactions myself.
I understand that there is a way to handle transaction controll in the
ZMySQL
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'
cursor.execute(query)
# get the next resultset, it has the result of the select
cursor.nextset()
result = cursor.fetchall()[0]
error = int(result[1])
if error:
    print "error %s when trying to add user %s" % (ERRRORS[error],
'JohnTheUser')
    db.rollback()
    continue #we are in a loop actually
..
db.commit()

How can I mimic that using ZSQL Methods

thanks for any pointers
Robert

-------------- next part --------------
A non-text attachment was scrubbed...
Name: robert.vcf
Type: text/x-vcard
Size: 200 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20070110/cf41a91b/robert.vcf


More information about the Zope mailing list