这是一个创建于 3883 天前的主题,其中的信息可能已经有所发展或是发生改变。
from flask.ext.sqlalchemy import SQLAlchemy
是这样的,之前也一直没遇到,今天进行环境迁移后,发现有下面的问题,但不是每次都出现:
##插入数据
rs_entity = Rs.query.filter_by(lb_id=lb_id).first()
if rs_entity is not None:
rs_entity.ip = vm['address']
db.session.merge(rs_entity)
db.session.commit()
else:
new_rs_entity = Rs(lb_id, vm['address'], 'inactive')
db.session.add(new_rs_entity)
db.session.commit()
##取数据
rs_entity = Rs.query.filter_by(lb_id=lb_id).first() ---这里会报错,说找不到
请问这个如何解析。
2 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
casparchen 2014-03-04 19:32:03 +08:00
Rs.query.filter_by(Rs.lb_id=lb_id).first() 试试把Rs加上呢?
|
|
|
2
tongle 2014-03-14 16:22:04 +08:00
是sqlalchemy的版本问题吗?
|