python cx_Oracle连接远程错误

时间:2017-11-20 07:28:09

标签: python oracle

我想用python连接到远程oracle database并尝试创建一个pandas数据帧:

con = ora.connect('user/pass@remote_ip/XE')
query = "select * from my_table"

df = pd.read_sql(query, con)

我正在使用macOS high siera,这就是我的主机文件的样子:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost local
127.0.0.1 localhost localhost.localdomain local lynx
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1     activate.adobe.com
127.0.0.1     practivate.adobe.com
127.0.0.1     hlrcv.stage.adobe.com
127.0.0.1     na1r.services.adobe.com
127.0.0.1 quickplayer.tvgo.hu
80.211.194.173 anton
10.2.94.217 lynx

我遇到cx_Oracle.DatabaseError: ORA-21561: OID generation failed错误。

如果我从Ubuntu尝试它的工作。

我的数据库版本:

Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE     11.2.0.2.0            Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

我该怎么办?

1 个答案:

答案 0 :(得分:2)

评论摘要:

运行主机名以获取您的操作系统认为您的名字。

在这种情况下,主机名返回QGMAC.local

将此行添加到您的主机文件中:

127.0.0.1 QGMAC.local

来自Don Burleson的网站:

http://www.dba-oracle.com/t_ora_21561_oid_generation_failed.htm

" ...问题很可能发生在客户端计算机主机文件中。检查客户端计算机主机文件中是否存在客户端计算机完全限定名称和短名称。"

相关问题