I'm trying to insert data with a date to MS Access using the pyodbc library in Python. My table has 3 fields: Date (Date/Time), 1Y (Number), and 2Y (Number). I know the problem is not a connection issue since I'm able to insert successfully without the Date field. For example, this works:
cursor.execute("insert into test(1Y,2Y) values (?,?)",'3','4')
Now including the Date, I've tried:
cursor.execute("insert into test(Date,1Y,2Y) values (?,?,?)",'2010-01-01','3','4')
cursor.execute("insert into test(Date,1Y,2Y) values (?,?,?)",date(2010,1,1),'3','4')
cursor.execute("insert into test(Date,1Y,2Y) values (?,?,?)",'1/1/2010','3','4')
For the above examples with Date, I receive the following error: ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (-3502) (SQLExecDirectW)')
I'm using Python 2.7, MS Access 2013, pyodbc 2.7. Thanks.