【发布时间】:2011-07-06 15:04:34
【问题描述】:
我的旧版 mysql 4.0.20 服务器在 Windows 机器上。 我正在Linux上开发一个新系统(基于python),需要连接到旧服务器并进行查询等。 我已经使用普通的 MySQLdb 和 django 成功连接。我在使用 sqlalchemy 连接时遇到问题。代码如下:
conn_str = "mysql://user:pass@192.168.171.233/dbd"
engine = create_engine(conn_str, echo=True)
metadata = MetaData(engine)
connection = engine.connect()
以及我得到的错误堆栈:
2011-03-01 08:35:04,613 信息 sqlalchemy.engine.base.Engine.0x...b42c SELECT DATABASE() 2011-03-01 08:35:04,613 信息 sqlalchemy.engine.base.Engine.0x...b42c () Traceback(最近一次调用最后一次):
连接 = engine.connect() 连接中的文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/base.py”,第 1811 行 返回 self.Connection(self, **kwargs) init 中的文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/base.py”,第 832 行 self.connection = connection 或 engine.raw_connection() 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/base.py”,第 1874 行,在 raw_connection 返回 self.pool.unique_connection() 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 142 行,位于 unique_connection return _ConnectionFairy(self).checkout() 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 369 行,在 __init rec = self._connection_record = pool.get() 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 213 行,在 get 返回 self.do_get() do_get 中的文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 732 行 con = self.create_connection() 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 147 行,在 create_connection 返回 _ConnectionRecord(self) init 中的文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/pool.py”,第 258 行 l.first_connect(self.connection, self) 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/strategies.py”,第 151 行,在 first_connect dialect.initialize(c) 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/dialects/mysql/base.py”,第 1753 行,初始化 default.DefaultDialect.initialize(self, connection) 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/default.py”,第 159 行,初始化 self.returns_unicode_strings = self._check_unicode_returns(连接) _check_unicode_returns 中的文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/default.py”,第 205 行 unicode_for_varchar = check_unicode(sqltypes.VARCHAR(60)) 文件“/usr/local/lib/python2.6/dist-packages/sqlalchemy/engine/default.py”,第 195 行,在 check_unicode ]).compile(方言=自己) 文件“/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/cursors.py”,第 173 行,在执行 self.errorhandler(self, exc, value) 默认错误处理程序中的文件“/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/connections.py”,第 36 行 引发错误类,错误值 ProgrammingError: (1064, "You have an error in your SQL syntax. Check the manual that applicable to your MySQL server version for the right syntax to use near '(60)) AS anon_1' at line 1")
【问题讨论】:
标签: mysql sqlalchemy