我有下面的代码,我希望我的 MySQL 查询在“名称”列中选择与“文件名”python 列表中的值相同的那些值。对于结果,我一直得到一个空的 ()。谁能帮我这个?
import MySQLdb
import fnmatch
import os
import pprint
connect = MySQLdb.connect(host = "123.5.4.4", port=3366, user = "me", passwd="*********", db="data2")
filenames=[]
maindict = {}
for root, dirnames, filenames in os.walk('d:/data1'):
for filename in fnmatch.filter(filenames, '*.txt'):
filenames.append(filename)
with connect:
cur= connect.cursor()
cur.execute("SELECT version,name FROM data2.files WHERE name IN ('filenames'.join('')" )
result = cur.fetchall()
pprint.pprint(result)