I’m trying to insert a row into a table that I’ve set up in a database.
My Code:
cursor.execute("""INSERT INTO scan (prefix, code_id, answer, station) VALUES(%s, %s, %s, %s, timestamp, comport)""",[(prefix, code_id, answer, station)])
I’m getting for an error that is saying that it doesn’t like what is in “[]”.
I don’t completely understand how “%s” works. I’ve tried many examples and all have failed me.
I got this example from http://mysql-python.sourceforge.net/MySQLdb.html
Why do you have the parameters inside two sets of brackets? The second argument should be a sequence containing four items, to match the four
%ss in your query. Instead, you have given it a list containing one item: that item is a sequence with four items in it.Instead, try: