from sqlalchemy.dialects.mysql.base import MySQLDialect
def _get_server_version_info(self, connection):
# get database server version info explicitly over the wire
# to avoid proxy servers like MaxScale getting in the
# way with their own values, see #4205
dbapi_con = connection.connection
cursor = dbapi_con.cursor()
cursor.execute("show global variables like 'version_comment'")
val = cursor.fetchone()
if val:
if'OceanBase'in val[1]:
val = '5.6.0'else:
cursor.execute("SELECT VERSION()")
val = cursor.fetchone()[0]
cursor.close()
from sqlalchemy import util
if util.py3k and isinstance(val, bytes):
val = val.decode()
return self._parse_server_version(val)
setattr(MySQLDialect, '_get_server_version_info', _get_server_version_info)