I have a problem with updating an existing Access table. I have an Access database that's supposed to sort some .log files with two columns: filename
and filedate
. I have the filename and filedate in an Excel file that I have made from sorting through 100+ .log files, so there are 100+ files that should be linked to Access
I get an error every time and have tried many different things. The problem is that I don't know how to write the syntax. Can someone help me with that please? I want A -> filename
and B -> filedate
so that every pair gets its own ID
import pypyodbc
UDC = r'C:\Users\Kaiser\Documents\Access\UDC.accdb'
# DSN Connection
#constr = " DSN=MS Access Database; DBQ={0};".format(UDC)
# DRIVER connection
constr = "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL={MS Access};DriverId=25;DefaultDir=C:/USERS/DOCUMENTS/ACCESS;DBQ=C:/USERS/DOCUMENTS/ACCESS/UDC.accdb"
# Connect to database UDC and open cursor
db = pypyodbc.connect(constr)
cursor = db.cursor()
sql = "UPDATE * INTO [tblLogfile]" + \
"FROM [Excel 8.0;HDR=YES;Database=C:/Users/Documents/Access/Excel.xls].[Tab$];"
cursor.execute(sql)
db.commit()
cursor.close()
db.close()
error
pypyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.')