本文介绍了cx_Oracle.InterfaceError:无法在Linux中获取Oracle环境句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用cx_Oracle模块连接到数据库,但出现错误
I am trying to connect to database using cx_Oracle module i am getting below error
server_IP = ipaddress:1221/xyz
try:
db = cx_Oracle.connect('username', 'password', server_IP)
print db
except cx_Oracle.DatabaseError as e:
error, = e.args
if error.code == 1017:
print('Please check your credentials.')
else:
print('Database connection error: %s'.format(e))
raise
我的问题是我是否需要在linux中安装任何oracle客户端或如何在linux中对其进行配置,以免出现此错误.请帮忙在Linux中使用cx_Oracle模块需要哪些先决条件
My question do i need to install any oracle client in linux or how to configure it in linux so that i won't get this error. please helpWhat are the preconditions are required in linux to use cx_Oracle module
推荐答案
请检查调用cx_Oracle.connect
的语法.它需要用户名,密码和DSN或一个包含所有参数的参数.
Please check the syntax of your call to cx_Oracle.connect
. It takes username, password and DSN OR one argument that has it all.
例如
con = cx_Oracle.connect('username/password@ipaddress/xyz')
或构建完整的DSN:
ip = 'ipaddress'
port = 1221
SID = 'xyz'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
db = cx_Oracle.connect('username', 'password', dsn_tns)
这篇关于cx_Oracle.InterfaceError:无法在Linux中获取Oracle环境句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!