Right now I am trying to make a script which will parse through a ton of inventory data and store it into a database so it will be easier to process later on. The program is able to take the parameters I need from a given product and store the data for that product into a dictionary. The idea was to then take that dictionary and move all of the data into a sqlite3 table using the executemany module as seen below.
# Write to database
# Write the current values to the database
sqlcursor.executemany("INSERT INTO {} VALUES(?, ?)".format(DBASENAME), rowdict)
Based on all of the research I have done, this command SHOULD work. The dictionary I am using has both the corresponding header name for the table I am trying to import to and the data I am trying to import into each respective column. An example of said dictionary is as follows (Edited to hide product data):
{'ID': 1, 'DIV': 'ST', 'SPECSHOP_UNICODE': 'Bath', 'RANGEGROUP_UNICODE': 'Around the shower', 'ARTNO': '40442069', 'ARTNAME_UNICODE': 'Floor Mat', 'SLID': '212100', 'PLANNED': 'Yes', 'ASSQ': '4', 'SSQ': '4', 'MIN': '6', 'MAX': '55', 'RSSQ': '7', 'RSSQ_FF': 'NOT OK', 'PALQ': '432', 'AVAILSTOCK': '0', 'QTYSGF': '0', 'NEXT_PLANNED_IND': '20200420', 'QTY_ORD': '12'}
When I try to run the code, I get the following error:
sqlcursor.executemany("INSERT INTO {} VALUES(?, ?)".format(DBASENAME), rowdict)
sqlite3.OperationalError: table slm3_01022022 has 19 columns but 2 values were supplied
As a side note, I have already tried removing the brackets and .format" at the end of the line, however, even without the string formatting, I still get the same error.
What would I have to do differently to get the script to add the entire dictionary to the database?