robert rottermann schrieb:
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.

Can you elaborate on that? I dont see a reason why you would
commit around zopes transaction handling (which would actually
be dangerous anyway - think of the retry mechanism in case of
database conflicts)

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.

Well most databases accept "COMMIT" as sql command.

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

what does the loop?
How can I mimic that using ZSQL Methods

Are you adding users in a series? What exactly
are you doing? If its kind of migation, consider
running it as a script with zopectl run
once. There you could just write python code as you like
w/o interfering w/ Zopes session handling.


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

Reply via email to