I need to execute query against DB, to check if file exist in DB and what is file modified time. function arguments are name(file name) and mtime1 (mod time from filesystem). I use script:
def chkModTS(name,mtime1):
import mysql.connector
cnx = mysql.connector.connect(user='uname', password='pass', host='192.168.1.1', database='newpms')
cursor = cnx.cursor()
query=("SELECT mtime FROM pf_scanOrd WHERE filename=%s")
query_data=(name)
cursor.execute(query,query_data)
print(cursor.rowcount)
if cursor.rowcount==-1:
chkModTS.upd=1
print('pole DBs')
return
for (mtime) in cursor:
print(float(mtime[0])!=mtime1)
if float(mtime[0])!=float(mtime1):
chkModTS.upd=1
print('need update')
return
cursor.close()
cnx.close()
When i run this function, result would be:
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1
cant figure out, need help