I created a table in Access and the connection works, but my loop through my dataframe using iterrows() is throwing a syntax error.
I have tried removing spaces and altering the syntax.
for index, row in futures_table.iterrows():
cursor.execute('''
INSERT INTO cme_oil_futures (MONTH,SETTLE,DATE,REPORT_TYPE)
VALUES (?,?,?,?)
''',(row['MONTH'],row['SETTLE'],row['DATE'],row['REPORT_TYPE']))
conn.commit()
Expected result is to insert the values for each row in the "MONTH", "SETTLE", "DATE", and "REPORT_TYPE" columns from my dataframe.
The error I get is "
Exception has occurred: pyodbc.ProgrammingError ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (-3502) (SQLExecDirectW)') File "E:\Python\DDWebsraping\cme_oil.py", line 83, in ''',(row['MONTH'],row['SETTLE'],row['DATE'],row['REPORT_TYPE']))
futures_table.to_sql()rather than iteration? - mad_?the correct placeholder token? - John GordonDATEa reserved word? - John Gordon