使用Python连接到Oracle数据实例的问题

问题描述 投票:0回答:1

我正在尝试使用Python脚本连接到Oracle数据实例(ORAD)。

这是基本脚本:

import cx_Oracle
conn = cx_Oracle.connect("username/password@//server:1560/orad")
c = conn.cursor()
c.execute('select distinct * from table1')
for row in c:
   print(row)
conn.close()

如果有帮助的话,我目前也有portSIDhostname的实例。

运行此脚本会产生:cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor错误, 使用其他连接(已注释掉)会产生错误SyntaxError: invalid syntax

我不确定我做错了什么。我确实检查了我的TNSNAMES.ORA文件,其中包含一些ifile链接到DBA安全(我无权查看或编辑)其他文件。

我查看了this postthis post,但我没有IP,只有主机名。

任何援助将不胜感激。

python-3.x oracle cx-oracle
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.