here is the code
sql="SELECT node_id FROM %s WHERE domain='%s';"%(config.nodetable,url)
r=getBySql(sql)
my problem is trying to save data in mysql db so this code should was executed repeatedly for like more than hundred thousands of times. and at the beginning everything went well, until several times the interpretor return the error:
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35,
in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'h' in 'where clause'")
but I find the sql string to be executed is totally OK as:
SELECT node开发者_开发问答_id FROM testnodewww WHERE domain='http://service.qq.com';
I totally have no idea about it. why it was working good at first? and why the error informed of "unknown column 'h'"?? my code have nothing to do with column h at all...
MySQLdb will convert your parameter into a SQL literal, do not use single quotes in your sql string, or a semi-colon at the end, and don't use string interpolation:
sql = "SELECT node_id FROM %s WHERE domain=%s" % (config.nodetable, url)
Do this instead:
cursor.execute("SELECT node_id FROM %s WHERE domain=%s", (config.nodetable, url))
精彩评论