首页 > 数据库技术 > 详细

Python2.X SQLAlchemy @@tx_isolation警告

时间:2019-10-23 00:56:24      阅读:122      评论:0      收藏:0      [点我收藏+]

警告信息:
Warning: ‘@@tx_isolation‘ is deprecated and will be removed in a future release. Please use ‘@@transaction_isolation‘ instead
  cursor.execute(‘SELECT @@tx_isolation‘)

 原因:

SQLAlchemy版本较老.

MySQL新版本更新了语法, SQLAlchemy却没有同步更新的情况下,出现的警告信息.

解决方案:

,在SQLAlchemy源码中添加Mysql语法判断.

 

# cd进对应SQLAlchemy的包目录, 更改dialects/mysql/base.py(请根据实际调整)

vim /.virtualenvs/py2/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py

查找并注释语句:

        cursor.execute(‘SELECT @@tx_isolation‘)

添加语句:

        if self.server_version_info < (5, 7, 20):
            cursor.execute(‘SELECT @@tx_isolation‘)
        else:
            cursor.execute(‘SELECT @@transaction_isolation‘)

 

, 更新SQLAlchemy版本

 

 

------------------一,原答案所在----------------

https://github.com/zzzeek/sqlalchemy/pull/391/files

Python2.X SQLAlchemy @@tx_isolation警告

原文:https://www.cnblogs.com/jrri/p/11723638.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!