我尝试发送此查询:
data = ('name')
query = ("SELECT %s FROM table")
cursor.execute(query,[data])
并打印整数:
b = cursor.fetchall()
for row in b:
a = row[0]
list_of_a.append(model)
return list_of_a
print list_of_a
并得到:
姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名 姓名
我尝试在其中进行查询(“从表中选择名称”)
我从“名称”列中得到:值1,值2,值3......等
最佳答案
像这样更改您的查询。
query = ("SELECT '%s' FROM table")
它会起作用。
关于Python2.7 + MySQL查询变量列返回变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37992030/