使用flask-sqlalchemy时遇到This result object does not return rows. It has been closed automatically.的错误提示

这个错误信息出现时的环境:

flask框架,mysql数据库。

错误语句:

current_app.db.session.execute(sql['update_circle_by_id'],params=circle_dict,bind=current_app.db.get_engine(current_app,bind='qcard')).fetchall()

SQL语句:

'update_circle_by_id': "UPDATE wyvern.xqcircle_circle SET circle_name = :circle_name, circle_description = :circle_description, is_toll = :is_toll, over_time = :over_time, group_buy_by_android = :group_buy_by_android, single_buy_by_android = :single_buy_by_android, group_buy_by_ios = :group_buy_by_ios, single_buy_by_ios = :single_buy_by_ios, circle_type = :circle_type, image = :image, image_join = :image_join, image_spell = :image_spell, image_banner = :image_banner, short_desc = :short_desc WHERE id = :circle_id",

SQL语句是没问题的,在数据库执行正常,经过测试发现只有insert或者update语句会出现这种错误提示。

解决方法:

去掉句尾的.fetchall()或者.fetchone()

posted @ 2019-07-17 09:33  Wuliwawa  阅读(2266)  评论(0编辑  收藏  举报