I have the below code in which I want my MySQL query select those values in the 'name' column that are identical to the value in 'filenames' python list. I keep get an empty () as for the result. Can anyone help me with this?
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)