【发布时间】:2016-12-30 01:06:40
【问题描述】:
我正在使用 flask 和 flask-SQLAlchemy 在 python 任何平台上开发一个 webapp。
我定义了评分表:
class Ratings(db.Model):
id = db.Column(db.Integer, primary_key=True)
section_id= db.Column(db.Integer, unique=False)
在我的机器上,我使用了一个 postgres 数据库,我这样做了:
db.session.bulk_insert_mappings(Ratings,[dict(section_id=1) for i in xrange(1,len(ratings))])
db.session.commit()
成功,并将数据帧加载到数据库。
当我在 python 任何平台上运行相同的代码时,使用 mysql 而不是 postgres,我收到消息:AttributeError: 'scoped_session' object has no attribute 'bulk_insert_mappings'
有人知道为什么会这样吗?
【问题讨论】:
标签: flask-sqlalchemy pythonanywhere