python db.commit_python,flask_db.session.commit()的时候抛出FlushError:,python,flask,sqlalchemy - phpStudy...

db.session.commit()的时候抛出FlushError:

class Epg_ps(db.Model):

__tablename__='epg_ps'

id = db.Column(db.String(50),primary_key=True)

pos_left =db.Column(db.Integer)

pos_top =db.Column(db.Integer)

pos_width =db.Column(db.Integer)

pos_height =db.Column(db.Integer)

epg_type=db.Column(db.Integer,db.ForeignKey('area_type.id'))

def __repr__(self):

return '' % self.id

class Epg_areaType(db.Model):

__tablename__='area_type'

id=db.Column(db.Integer,primary_key=True)

name=db.Column(db.String(50),unique=True)

type=db.Column(db.Integer,unique=True)

ps=db.relationship('Epg_ps',backref='type',lazy='dynamic')

def __repr__(self):

return '' % self.name

add=Epg_ps(id='regions_1',pos_left=34,pos_top=43,pos_width=43,pos_height=34,epg_type=1)

执行下面的代码的时候就

db.session.add(add)

db.session.commit()

抛出

FlushError: Instance has a NULL identity key. If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values. Ensure also that this flush() is not occurring at an inappropriate time, such aswithin a load() event.

相关阅读:

JS里面 方法.call()是什么?

前端 canvas 生成 pdf 有什么好的实践? (尤其是文件较大的情况下)

为什么最后滚动到最后一屏后自动往上滚。。

受的许多模拟的http请求,求解决方法。

angular ng-switch的用法

移动前端开发如何根据大尺寸的设计稿来进行布局,做到适应大部分移动设备?

windows 无法启动oraclemtsrecoveryservice服务 14001

java中如何让自定义异常像系统的那些异常一样不强制要求处理异常

springboot文件上传问题

segmentfault的APP是原生开发的还是混合开发的呢?

安卓开发中,在匿名类中为外部类赋值问题

怎样可以同时控制两条折线图

gcc或者ld链接时,默认链接的库有哪些,

前端如何引入页面呢?

js数组 对象过滤问题

价格正则表达式 来个

列表中元素顺序的问题?

要实现diy页面模板的功能,数据库应该怎么设计!

js频繁对接口轮询调用为何会偶尔报错?

attr()设置浮动为何不行?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值