开发者

SQLite: Constraint failed on Insert

I have one Auto Increment Field, rest are Integer,Text and Datetime field. How do I fix it out?

The Table Structure is given below:开发者_StackOverflow社区

CREATE TABLE "q1" (
     "sb_id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
     "sb_title" text(100,0) NOT NULL,
     "sb_details" text(300,0) NOT NULL,
     "sb_image" text(30,0) NOT NULL,
     "sb_type" integer(4,0) NOT NULL DEFAULT '1',
     "sb_date" datetime NOT NULL
)


It could be because in your insert command

connection.execute("INSERT INTO q1(sb_title,sb_details)VALUES(?,?)",a,b);

you didn't insert any values for sb_image or sb_date, both of which are NOT NULL and have no default defined. SQLite doesn't know what to put in there. You should either take away the NOT NULL constraint on those columns, define a default for the columns, or insert something explicitly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜