MySQL Forums
Forum List  »  Connector/Python

How to use PREPARED statements in pyhon-mysql?
Posted by: He Yu
Date: January 13, 2009 12:07AM

I've figured a plausible way of using several PREPARED statements in mysql 5.0 :
open connection
cursor.execute('prepare stmt1 from "..."')
cursor.execute('prepare stmt2 from "..."')
...
loop:
cursor.execute('set ...')
cursor.execute('execute stmt1 using (...)')
cursor.execute('set ...')
cursor.execute('execute stmt2 using (...)')
...
cursor.execute('deallocate prepare stmt1')
cursor.execute('deallocate prepare stmt2')
close connection

I try to put 'set'/'execute' in one clause, but it fails after executing a few. The current way incurs additional cost of executing 'set'. Most important of all, the performance is the same as that not using prepare.

Does Py-MySQL provide any better support for PREPARED statements, rather than executemany()?

Options: ReplyQuote


Subject
Written By
Posted
How to use PREPARED statements in pyhon-mysql?
January 13, 2009 12:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.