【发布时间】:2018-05-03 08:56:01
【问题描述】:
我想用 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
我应该尝试什么?
【问题讨论】:
-
用数据库版本更新了我的问题,它不在运行 macOS 的同一台机器上。数据库在 Ubuntu 机器上。
-
这是我的主机文件的样子:127.0.0.1 localhost localhost.localdomain 10.2.94.217 lynx 因为我的 oracle 服务器 ip 是 10.2.94.217 并且运行 oracle 服务器的 ubuntu 机器的主机名是 lynx .还是行不通。 :(
-
在 Mac 终端中输入
hostname会得到什么? -
QGMAC:~ gabor_dev$ 主机名 QGMAC.local
-
stackoverflow.com/questions/31338916/… 的副本也提供了解决方案。