I was creating queries in Python to populate rows in a local database using MySQL.
My variable product is a tuple, which holds 33 values. I want to add all of these values into appropriate columns listed in a table called roottable (which I created in dbForge). I was getting an error in line con.execute():
TypeError: not all arguments converted during string formatting
Not sure what I'm doing wrong. I am applying the same syntax as SQlite's. Here is my code:
connection = msql.connect(host = 'localhost', user = 'me', passwd = 'password', db = 'TESTDB')
with connection:
for product in list_product:
#Get a tuple of standardized informtaion to store in table
product = normalize_table_entry(product)
con = connection.cursor()
con.execute('INSERT INTO roottable VALUES (?,?,?,?,?,?,?,?,?,\
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', product)
#connection.commit()