DB Connect失败Python CX_oracle -ORA -01804
我尝试将Oracle DB与Python 3.9.7中的CX_oracle软件包连接起来。 cx_oracle版本为8.3.0。
当我尝试使用命令 cx_oracle.clientversion()我有错误时:
databaseError:错误试图检索文本以获取错误ora-01804
Linux OS,将我的 .bash_profile
与sqlplus命令i成功连接DB。
.bash_profile :
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当环境变量
oracle_home
的值与已加载的实际库之间存在差异时,通常会发生此错误。您可以将环境变量dpi_debug_level
设置为值64
并运行脚本。它将告诉您使用哪种方法来加载库。如果这无助于您弄清楚它,请将输出粘贴到您的问题中,我将尝试进一步帮助。还请注意,有一个新的驱动程序(Python-OracledB),该驱动程序不需要Oracle客户端库,因此不应该遇到此问题。在这里看: https://levelup.gitconnected.com/open-source-python-thin-thin-driver-for-oracle-oracle-database-e82aac7ecf5a
This error generally occurs when there is a discrepancy between the value of the environment variable
ORACLE_HOME
and the actual library that was loaded. You can set the environment variableDPI_DEBUG_LEVEL
to the value64
and run your script. It will tell you which method was used to load the library. If that doesn't help you figure it out, paste the output in your question and I'll try to help further.Note as well that there is a new driver available (python-oracledb) which doesn't require Oracle Client libraries and therefore shouldn't run into this issue. Take a look here: https://levelup.gitconnected.com/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a
在Windows下的完整Oracle客户端的情况下,我们确实遇到了此错误“数据库:错误:错误在试图检索错误的错误ORA-01804”中,并且我们花了很长时间才能解决它。在笔记本电脑上,指向bin-folder的路径变量中的Oracle客户端已经设置了通过Pythons脚本设置的唯一需要设置的环境变量,这是一个:
os.putenv('ld_library_path','c:c:c:c:c:c:c:c:c:c:c: \ ora19c64 \ product \ 19.3.0 \ client_64 \ bin')
这不是直观的指向ld_library_path到bin-folter而不是lib折叠器,但它解决了问题。
With a full Oracle client under Windows we did run into this error “DatabaseError: Error while trying to retrieve text for error ORA-01804” as well and it took us quite a while to solve it. With on the laptop the Oracle client in the Path-variable pointing to the bin-folder and with TNS_ADMIN already set the only needed environment variable to be set via the Pythons script was this one:
os.putenv('LD_LIBRARY_PATH', 'C:\Ora19c64\product\19.3.0\client_64\bin')
It is not intuitive to point for LD_LIBRARY_PATH to the bin-folder instead of the lib-folder, but it solved the issue.