Python2.X SQLAlchemy @@tx_isolation警告

警告信息:
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

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