1
est Sep 17, 2013
试试吧%s改成 ?
|
2
delo Sep 17, 2013 把 execute参数里 i 前面的逗号改成%(不知道我理解对不对… )
|
3
roricon Sep 17, 2013
cur.execute("""CREATE TABLE IF NOT EXISTS {0} (num VARCHAR(25))""".format(i))
|
4
cloverstd Sep 17, 2013
%s 改为 ?
或者 ,i 改为 % (i) |
5
msg7086 Sep 18, 2013
|
7
randal Sep 18, 2013 mysqldb表名不能参数绑定, 需要改成cur.execute("CREATE TABLE IF NOT EXISTS %s (num VARCHAR(25))" % i)
|
8
hjyoite Sep 18, 2013
我觉得7楼是对的。
|
9
inyfee Sep 18, 2013
7楼正解
|
10
lambdaT Sep 18, 2013
for i in l :
sqlStr='CREATE TABLE IF NOT EXISTS' +x ;; cur.execute(sqlStr) |
11
lambdaT Sep 19, 2013
变量不一致,改一下
|
12
likuku Sep 19, 2013
嗯,字符串替代就是这样子的:
print "this is test str: %s" % (test_str) |
13
est Sep 23, 2013
日。7楼说对了。
SQL真是一坨屎。说到底还是拼字符串。万一表名里包含 ` ; ' 等特殊字符就happy了。 |