Home > Enterprise >  Parameter error for pyodbc insert/apppend
Parameter error for pyodbc insert/apppend

Time:09-20

I am trying to insert/append into access a dataframe using pyodbc. However; when I run the code, I get an error: ProgrammingError: ('The SQL contains 21 parameter markers, but 1 parameter were supplied', 'HY000')

my sample code is: for row in tDjango: cursor.execute( 'INSERT INTO TDjango (Eid, Eventtype, Location, Lat, Lon, Created, TMCClosed,FirstArrival(min), PatrolArrival(min), TowArrival(min), LanesCleared(min), RoadwayCleared(min),Camera, DayofWeekOpened, DayofWeekClosed, sameDay, confirmClosed, confirmFirstAr, confirmPtrl, confirmTow, confirmLnClear) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',tDjango) conn.commit()

I’m not entirely sure what I am missing in the SQL statement to make the error go away.

CodePudding user response:

Instead of using cursor.execute(), I used cursor.executemany().

  • Related