欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Warning: (1287, @@tx_isolation is deprecated and will be removed in a future release

程序员文章站 2022-07-14 22:59:24
...

使用flask中使用SQL alchemy通过模型类创建数据表并保存数据时 会出现一个警告,不是错误!

并不会影响项目运行,如果项目启动不了,应该是别的地方出问题了。

 Warning: (1287, "'@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead")
翻译
@@tx_isolation被禁止使用并且在未来的版本中会被移除,请使用’@@transaction_isolation’代替

Warning: (1287, @@tx_isolation is deprecated and will be removed in a future release

解决办法
进入~/.virtualenvs/Flask_py/lib/python3.6/site-packages/sqlalchemy/dialects/mysql$ 目录找到base.py进行编辑

Warning: (1287, @@tx_isolation is deprecated and will be removed in a future release
然后加上

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

效果如下:
Warning: (1287, @@tx_isolation is deprecated and will be removed in a future release

代码地址: https://github.com/zzzeek/sqlalchemy/pull/391/files