I am trying to execute a query to insert two values into a simple table in an access database. But I got this error:
pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (-3502)(SQLExecDirectW)')
How should I write the date format? My code is like below (The code is working with only integers to insert so I think my date format is no correct):
import pyodbc
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb,*.accdb)};DBQ=C:\Users\behdad\Documents\Database1.accdb;')
cursor = conn.cursor()
cursor.execute("insert into Table1 (date, number) VALUES( '2021-02-05 00:00:00', 24)")
The sample table is here: date format in access
#instead'for delimiters. Date is a reserved word. Advise not to use reserved words as field names. If still have an issue, try[date].