【发布时间】:2015-09-11 07:01:27
【问题描述】:
我想从员工表中获取池号并将池号用作查询 1 的参数。我得到错误 python: cannot concatenate 'str' and 'tuple' objects。
import MySQLdb
import sys
factor_mm=sys.argv[1]
factor_yy=sys.argv[2]
con_pd1 = MySQLdb.connect('localhost', 'abc', '12345', 'test')
cursor_pd1=con_pd1.cursor()
query="select pool_number from employee where current_mm="+factor_mm+" and current_yy="+factor_yy+" ;"
cursor_pd1.execute(query)
pools=cursor_pd1.fetchall()
pool_list=[]
for pool in pools:
pool_list.append(pool[0])
for pool in pool_list:
pool_number=pool
try:
query1="select * from fnma_mbs where pool_number='"+pool_number+"' and current_mm="+factor_mm+" and current_yy="+factor_yy+" ;"
cursor_pd1.execute(query1)
cursor_seqdb1.execute(query1)
numrows_pd1=cursor_pd1.rowcount
numrows_seqdb1=cursor_seqdb1.rowcount
【问题讨论】:
-
在修改你的代码时,你解决了你的问题吗?还是你仍然得到你的错误?
-
不,实际上这是一个错误..仍然代码给出相同的错误
-
如果您不知道“SQL 注入”是什么或意味着什么,您现在应该停下来阅读一下。