开发环境:
mysql=8.0
pymql=0.8.0
sqlalchemy=1.2.4
创建数据库表项的时候出现以下错误:
(pymysql.err.InternalError) (1193, "Unknown system variable 'transaction_isolation'") (Background on this error at: http://sqlalche.me/e/2j85)
看Background的意思是这个问题是driver的问题,不是sqlalchemy的问题。
查到Django环境下的类似问题:
https://code.djangoproject.com/ticket/28804
里面提到:
@cached_property
def transaction_isolation_variable(self):
return 'tx_isolation' if self.mysql_version < (5, 7, 20) or self.mysql_version > (10, 0, 10) else 'transaction_isolation'
大意就是说早起版本的mysql中用的是tx_isolation,5.7.20版本之后,用的是transaction_isolation。
于是在mysql中查询transaction_isolation
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.2-dm