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 '<Epg_ps %s>' % 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 '<area_type %>' % 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 <Epg_ps at 0x7ffca0959950> 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.
魑魅魍魉X
10 years, 2 months ago