我有一个sqlalchemy表对象并尝试插入一些值,但它会引发错误,如
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) os_info.id may not be NULL'
我无法理解这是怎么发生的,因为我使用id
autoincrement=True
class Os(Base):
__tablename__ = 'os_info'
id = Column(Integer, autoincrement=True, primary_key=True)
hostname = Column(String(32), nullable=False)
dist = Column(String(32), nullable=False)
instruct_set = Column(String(32), nullable=False)
def __repr__(self):
return "<Os(hostname='%s',dist='%s',instruct_set='%s')>" % (self.hostname, self.dist, self.instruct_set)