469,626 Members | 989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

RE: a question about mysqldb

db module properly formats arguments, if input arguments are separated fromtable_name and colum_names.....

columns = ('tID', 'tNote')
table_name = 'tmp'
sql = 'select %s from %s where tID=:1' % ( ', '.join(columns), table_name)
cursor.execute(sql, (1,))

# sql is now 'select tID, tNote from tmp where tID=:1'
# note the comma in argument tuple to execute (1,)

thanks Edwin

-----Original Message-----
From: py************************************************ **@python.org
[mailto:py***************************************** *********@python.org]
On Behalf Of Eric Wertman
Sent: Thursday, August 14, 2008 2:13 PM
To: py*********@python.org
Subject: Re: a question about mysqldb
I also like to use escaped identifiers in cases like this:

sql = "select tID,tNote from %s where %s = %%s" % ("tmp","tID")

should work fine.
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
Aug 14 '08 #1
0 585

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dave Harrison | last post: by
1 post views Thread by Peter Nikolaidis | last post: by
1 post views Thread by Steve | last post: by
1 post views Thread by Yi Xing | last post: by
reply views Thread by Edwin.Madari | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.