MySQL dymanic query in Python
RAHUL RAJ
omrahulrajcse at gmail.com
Wed May 29 05:09:05 EDT 2013
Can anyone tell me the proper way in which I can execute dynamic MySQL queries in Python?
I want to do dynamic queries for both CREATE and INSERT statement.
Here is my attempted code:
sql="create table %s (%%s, %%s, %%s ... )" % (tablename,''.join(fields)+' '.join(types))
cur.execute(sql)
where 'field' is the fieldnames stored in a list and 'types' are the fieldtypes stored in a list.
More information about the Python-list
mailing list