Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46361
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-05-29 02:09 -0700 |
| Message-ID | <2fd0cae6-6cfe-4163-964e-2aa863e65f5e@googlegroups.com> (permalink) |
| Subject | MySQL dymanic query in Python |
| From | RAHUL RAJ <omrahulrajcse@gmail.com> |
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.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
MySQL dymanic query in Python RAHUL RAJ <omrahulrajcse@gmail.com> - 2013-05-29 02:09 -0700
Re: MySQL dymanic query in Python Fábio Santos <fabiosantosart@gmail.com> - 2013-05-29 11:02 +0100
Re: MySQL dymanic query in Python RAHUL RAJ <omrahulrajcse@gmail.com> - 2013-05-30 05:22 -0700
csiph-web