· 8 years ago · Apr 18, 2018, 07:48 AM
1c = conn.cursor()
2s = 'CREATE TABLE IF NOT EXISTS ' + tabname + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, date text, cat text, nameproduct text, price int);'
3c.execute(s)
4conn.commit()
5c.executemany("INSERT INTO :tabname VALUES (date = :date, cat = :cat, nameproduct = :nameproduct price = :price)", {"tabname" : tabname, "date" : tableinsert[0], "cat" : tableinsert[1], "nameproduct" : tableinsert[2], "price" : tableinsert[3]})
6
7c.executemany("INSERT INTO :tabname VALUES (date = :date, cat = :cat, nameproduct = :nameproduct price = :price)", {"tabname" : tabname, "date" : tableinsert[0], "cat" : tableinsert[1], "nameproduct" : tableinsert[2], "price" : tableinsert[3]})
8sqlite3.OperationalError: near ":tabname": syntax error