Last active
December 16, 2015 14:39
-
-
Save lexdene/5450648 to your computer and use it in GitHub Desktop.
I think this is a bug in MySQLdb .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MySQLdb | |
conn = MySQLdb.connect(user='xxx',passwd='xxx',db = 'xxx') | |
cursor = conn.cursor() | |
n = cursor.execute( | |
'select * from xxx where `content` in %(content)s', | |
{ 'content': ('aa','bb','cc') } | |
) | |
print cursor._last_executed | |
# I hope it print: | |
# select * from xxx where `content` in ('aa', 'bb', 'cc') | |
# but actually it print: | |
# select * from xxx where `content` in ("'aa'", "'bb'", "'cc'") | |
# and because of this , the query fetch nothing | |
# Is this a bug of MySQLdb ? | |
# my system: | |
# Ubuntu 12.04.2 LTS | |
# Python 2.7.3 | |
# MySQLdb 1.2.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment