无法从 Python 连接到 ODBC 错误:找不到文件 (0) (SQLDriverConnect)")



我正试图通过pyodbc驱动程序在Linux服务器上使用Python连接到oracle数据库。但我得到以下错误:

File "Query.py", line 20, in <module>
connection = pyodbc.connect('Driver=/usr/lib/oracle/18.3/client64/lib/libsqo                                                                                                                     ra.so.18.1};DBQ=bnpporacleb.chwk19l2i1ki.ap-southeast-1.rds.amazonaws.com/ORCL;U                                                                                                                     id=admin;Pwd=12341234')
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/                                                                                                                     lib/oracle/18.3/client64/lib/libsqora.so.18.1}' : file not found (0) (SQLDriverC                                                                                                                     onnect)")

我还尝试在odbcinst.ini:中输入

[MyOracle]
Description=Oracle Unicode driver
Driver=/usr/lib/oracle/18.3/client64/lib/libsqora.so.18.1
UsageCount=1

但出现错误:

File "Query.py", line 19, in <module>
connection = pyodbc.connect('Driver=MyOracle};DBQ=xxxxx/ORCL;Uid=admin;Pwd=12341234')
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'MyOracle}' : file not found (0) (SQLDriverConnect)")
FileUsage=1

下面的dltest命令运行良好。

[root@ip-172-31-33-62 lib]# dltest /usr/lib/oracle/18.3/client64/lib/libsqora.so.18.1
SUCCESS: Loaded /usr/lib/oracle/18.3/client64/lib/libsqora.so.18.1

此外,以下命令给出了所提到的输出:

[root@ip-172-31-33-62 etc]# python -c "import pyodbc; print(pyodbc.connect('DRIVER=MyOracle;DBQ=XXXXX/ORCL;UID=admin;PWD=12341234'))"
<pyodbc.Connection object at 0x7fba233664e0>
ls -l /usr/lib/oracle/18.3/client64/lib/libsqora.so.18.1

对该文件有什么权限?

您的Python进程是否以能够读取和/或执行它的用户身份运行?

相关内容

  • 没有找到相关文章

最新更新