Instead of
connect.execute('''
INSERT INTO ssrb (date, time_in, time_out, company, plate, province, driver, pass1,
pass2, pass3, deliver, contact, entry_by, pi_yes, pi_no, pi_violations, pi_done_by,
vi_yes, vi_no, vi_violations, vi_done_by)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s), (Date, TimeIn, TimeOut, Company, Plate, Province, Driver, Pass1, Pass2, Pass3,
Delivery, Contact, EntryBy, PIYES, PINO, PIFound, PIDoneBy, VIYES, VINO,
VIFound, VIDoneBy)
''')
use
connect.execute('''
INSERT INTO ssrb (date, time_in, time_out, company, plate, province, driver, pass1,
pass2, pass3, deliver, contact, entry_by, pi_yes, pi_no, pi_violations, pi_done_by,
vi_yes, vi_no, vi_violations, vi_done_by)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?)''', (Date, TimeIn, TimeOut, Company, Plate, Province, Driver, Pass1, Pass2, Pass3,
Delivery, Contact, EntryBy, PIYES, PINO, PIFound, PIDoneBy, VIYES, VINO,
VIFound, VIDoneBy)
)
They are 2 differences:
- Symbol
?
instead of %s
as it is not a Python's syntax for the string's .format()
method (or older %
notation) but the DB-API’s parameter substitution symbol.
- Ending
'''
are moved up - where the INSERT INTO
(parametrized) statement really ends.
(The substitution itself is performed by the .execute()
method by its 2nd parameter - a tuple provided by you.)