I have a query which should insert the contents of a list to a table. It's my understanding that each %s should be replaced by the content of the valueInsert list I've added to the execute command.
However I get the following error
c.executemany(test4, valuesInsert)
sqlite3.OperationalError: near "%": syntax error
Query:
test4 = "INSERT INTO test (city,region_code,os,ip,isp,area_code,\
dma_code,last_update,country_code3,country_name,postal_code,\
longitude,country_code,ip_str,latitude,org,asn) VALUES \
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
Command to execute query
c.executemany(test4, valuesInsert)
Contents of List:
['Norwell', 'MA', None, 1572395042, 'EdgeCast Networks', 781, 506, '2019-12-09T00:44:43.812333', 'USA', 'United States', '02061', -70.8217, 'US', '93.184.216.34', 42.15960000000001, 'Verizon Business', 'AS15133']
"INSERT INTO test (city,region_code,os,ip,isp,area_code,\ dma_code,last_update,country_code3,country_name,postal_code,\ longitude,country_code,ip_str,latitude,org,asn) VALUES \ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"I get the errorsqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 17, and there are 7 supplied.but when I print the list I'm seeing 17 attributesexecutemanyyou should use list of lists -[ ['Norwell',... ], ['other place', ...], ]for single element (like yours) you haveexecute()