Inserting SQLite primary key in python -


i trying sqlite insert python script.

i getting error:

table history has 4 columns 3 values supplied 

the reason there 3 not 4, first 1 id. assumed declared primary key auto-increment value. how go inserting id

.py:

c.execute("insert history values (?,?,?)", (q[0],t,in)) 

.db

create table history (id integer primary key, employeeid integer, time datetime, inout varchar); 

you either have provide values all columns, or name columns inserting explicitly. sqlite not go , guess columns provided values for, need explicit them.

you can use null have sqlite insert auto-generated id you:

c.execute("insert history values (null,?,?,?)", (q[0],t,in)) 

or can name 3 columns inserting explicitly:

c.execute("insert history (employeeid, time, inout) values (?,?,?)", (q[0],t,in)) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -