NOT NULL constraint failed: .id

A. 问题描述

在使用Python使用sqlite3数据库时,写入数据出现报错: NOT NULL constraint failed: *.id

B. 问题分析

根据报错分析应该是数据库中的非空约束添加的问题,查看数据库字段


NOT NULL constraint failed: .id_第1张图片
字段详情

想着是不是主键没有自增的缘故?
于是添加约束:


NOT NULL constraint failed: .id_第2张图片
添加约束

调试还是报错。

想着应该是长度的原因,修改长度为0,

修改长度

存储正常,End ~

参考:

https://blog.csdn.net/superit401/article/details/78237780
http://www.cnblogs.com/echo-something/archive/2012/08/26/mysql_int.html

你可能感兴趣的:(NOT NULL constraint failed: .id)