SQL Alchemy 和 CX_Oracle 反射问题
我在使用 cx_Oracle 版本 5.1 (autoload=True) 反映 Oracle 中的表时遇到问题。在 cx_Oracle 版本 5.0.4 下一切正常。这是我得到的错误:
DatabaseError: (DatabaseError) ORA-01460: unimplemented or unreasonable conversion requested
不知何故,发送到 Oracle 的查询没有正确替换表名和模式。有没有人见过这样的事情并有解决方案?我想避免为所有表手动定义列。如果可能的话,我也想使用最新版本。
I am having problems reflecting tables in Oracle using cx_Oracle version 5.1 (autoload=True). Everything works fine under cx_Oracle version 5.0.4. Here's the error I get:
DatabaseError: (DatabaseError) ORA-01460: unimplemented or unreasonable conversion requested
Somehow, the query sent to oracle is not substituting the tablename and schema correctly. Has anybody seen anything like this and have a solution? I'd like to avoid to define columns manually for all the tables. I also want to use the latest versions if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚提交了一个补丁来为我解决这个问题。 cx_Oracle 添加了对 Unicode 的支持,后来又删除了。 SQLAlchemy 的 cx_oracle.py 中有几行用于检查 cx_Oracle 模块的版本。该补丁更新了这些版本检查以考虑恢复的 Unicode 支持。
我认为正是您的问题帮助我在几周前第一次让 SQLAlchemy 与 cx_Oracle 一起工作,所以感谢您的提问! :-D
I just submitted a patch that fixes this issue for me. Support for Unicode was added to cx_Oracle and then later removed. There are a few lines in SQLAlchemy's cx_oracle.py that check the version of the cx_Oracle module. The patch updates these version checks to take into account the reverted Unicode support.
I think that it was your question that helped me get SQLAlchemy working with cx_Oracle for the first time a few weeks ago, so thanks for asking! :-D
正如 Alex 补丁的线程中所讨论的,解决方案是设置 NLS_LANG 环境变量,以便 cx_oracle 可以使用正确的转换器。例如:
As discussed in the thread for the patch of Alex, a solution is to set the NLS_LANG environment variable, so that cx_oracle can use the right converter. For example: