info = "'INSERT INTO brush_card_record(brush_card_date, brush_card_time, card_num_6061, card_num_6654) VALUES(?,?,?,?)',('2017-05-28','12:23:32', 123, 0)"
cur.execute(info)
This will report an error: sqlite3.OperationalError
cur.execute('INSERT INTO brush_card_record(brush_card_date, brush_card_time, card_num_6061, card_num_6654) VALUES(?,?,?,?)',('2017-05-28','12:23:32', 123 , 0))
This will work.
cur.execute has two parameters, one is SQL, and the other is to pass the value to the SQL parameter. Your first sentence enclosed in double quotes is equivalent to a string, that is, a parameter, and the second parameter is not passed in
info = "INSERT INTO brush_card_record(brush_card_date, brush_card_time, card_num_6061, card_num_6654) VALUES(%s,%s,%s,%s)"%('2017-05-28','12:23:32', 123, 0)
或者str.format
The question has been found, thank you for the answer!
When inserting new data into the database table is dynamic, a better way is to generate str first and then pass it into cur.execute() as a parameter.
Code example: