无法将 NULL 插入列 'Type'
Cannot insert NULL into column 'Type'
我正在尝试将包含两条信息的行添加到注释 table。我正在使用 python 执行以下 INSERT
语句。
cursor.execute("insert into Notes(Notes, NumericKey) values (?, ?)",Tracking, OrderNumber)
我遇到的错误
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
IntegrityError: ('23000', "[23000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot insert the value NULL into column 'Type', table 'beltoutlet.dbo.Notes'; column does not allow nulls. INSERT fails. (515) (SQLExecDirectW); [01000] [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. (3621)")
我看到很多人遇到类似的问题,但所有尝试的解决方案都没有帮助。我无计可施,因为 Tracking 和 OrderNumber 都有实际值,而且我没有列 "Type"。任何帮助将不胜感激。
我同意 Aaron Dietz 的评论,即被引用的 table(不一定是您要引用的 table)有一个类型列。为了补救这种情况,我相信你有两个选择:
1) 使用数据库和模式名称
具体 table
cursor.execute("insert into [databaseName].[SchemaName].[Notes](Notes, NumericKey) values (?, ?)",Tracking, OrderNumber)
2)(不推荐)通过设置一个假值(如空字符串)强制插入
cursor.execute("insert into Notes(Notes, NumericKey, [Type]) values (?, ?, ?)",Tracking, OrderNumber, '')
希望对您有所帮助。
我正在尝试将包含两条信息的行添加到注释 table。我正在使用 python 执行以下 INSERT
语句。
cursor.execute("insert into Notes(Notes, NumericKey) values (?, ?)",Tracking, OrderNumber)
我遇到的错误
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
IntegrityError: ('23000', "[23000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot insert the value NULL into column 'Type', table 'beltoutlet.dbo.Notes'; column does not allow nulls. INSERT fails. (515) (SQLExecDirectW); [01000] [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. (3621)")
我看到很多人遇到类似的问题,但所有尝试的解决方案都没有帮助。我无计可施,因为 Tracking 和 OrderNumber 都有实际值,而且我没有列 "Type"。任何帮助将不胜感激。
我同意 Aaron Dietz 的评论,即被引用的 table(不一定是您要引用的 table)有一个类型列。为了补救这种情况,我相信你有两个选择:
1) 使用数据库和模式名称
具体 tablecursor.execute("insert into [databaseName].[SchemaName].[Notes](Notes, NumericKey) values (?, ?)",Tracking, OrderNumber)
2)(不推荐)通过设置一个假值(如空字符串)强制插入
cursor.execute("insert into Notes(Notes, NumericKey, [Type]) values (?, ?, ?)",Tracking, OrderNumber, '')
希望对您有所帮助。