Parameter error for pyodbc insert/apppend

Question:

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.

Asked By: joshuah9

||

Answers:

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

Answered By: joshuah9
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.