DB Connect失败Python CX_oracle -ORA -01804

发布于 2025-02-13 17:49:04 字数 538 浏览 0 评论 0 原文

我尝试将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

”在此处输入图像说明”

谢谢

I try to connect oracle DB with cx_Oracle package in python 3.9.7.
cx_Oracle version is 8.3.0.

when i try to connect with command cx_Oracle.clientversion() i got error :

DatabaseError: Error while trying to retrieve text for error ORA-01804

Linux Os , attach my .bash_profile

with sqlplus command i success to connect the DB.

.bash_profile :

enter image description here

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻的心爱 2025-02-20 17:49:04

当环境变量 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 variable DPI_DEBUG_LEVEL to the value 64 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

当梦初醒 2025-02-20 17:49:04

在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文