cur.execute('INSERT INTO company VALUES (%(cname), %(symbol), %(start_date), %(end_date))' %{'cname' : company, 'symbol' : company, 'start_date' : startdate, 'end_date' : enddate})
Trying to run this line on my computer results in a string formatting error: ValueError: unsupported format character ',' (0x2c) at index 36
It seems to be concerning the ,
but I have checked and all the parenthesis are properly nested (none enclosing an errant ,
)
You need an "s" after each of those positional arguments.
(%(cname)s, %(symbol)s, ....
What @imm said. Also, you may want to use the built in query formatting that is part of MySQLdb.
cur.execute("INSERT INTO company VALUES (%s, %s, %s, %s)", (company, company, startdate, enddate))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With