当我通过 SQLAlchemy(版本 1.0.8)连接到 MemSQL 时,我 我收到一个错误
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`Charset` = 'utf8' and `Collation` = 'utf8_bin'' at line 1") [SQL: "show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'"]
echo=True表示一开始SQLAlchemy执行了如下命令
show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'
当我手动运行上面的命令时,我遇到了同样的错误,但是当我删除 Charset 和 Collation 周围的字符 (`) 时,查询运行正常。这是 MemSQL 问题吗?
顺便说一句,我使用默认(MySQL)方式连接到 MemSQL。
engine = create_engine('mysql://root@127.0.0.1:3306', echo=True)
请您参考如下方法:
这看起来像是一个合法的错误。看来这是由最近在 SQLAlchemy 中使用 MySQL-Python 库的代码中引入的更改/解决方法引起的。我们将努力为我们这边打补丁。
与此同时,OurSQL 库工作正常:
>>> import sqlalchemy
>>> sqlalchemy.__version__
'1.0.8'
>>> sqlalchemy.create_engine("mysql+oursql://127.0.0.1").connect()
<sqlalchemy.engine.base.Connection object at 0x7f382ff19910>
