lundi 16 mars 2015

Inserting SQLite primary key in python

I am trying to do a SQLite insert from my python script.


I am getting an error:



table history has 4 columns but 3 values were supplied


The reason there is 3 not 4, is that the first one is my ID. I assumed that as i declared it as a primary key it would auto-increment the value. How do I go about inserting the ID


.py:



c.execute("INSERT INTO history VALUES (?,?,?)", (q[0],t,in))


.db



CREATE TABLE history (id integer primary key, employeeID integer, time datetime, inout varchar);

Aucun commentaire:

Enregistrer un commentaire