如何使用python中的SCAN连接到Oracle-RAC? [英] How to connect to Oracle-RAC using SCAN in python?

查看:448
本文介绍了如何使用python中的SCAN连接到Oracle-RAC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cx_Oracle模块如下连接到独立的Oracle服务器

I use cx_Oracle module to connect to standalone Oracle server as follows

import cx_Oracle

CONN_INFO = {
    'host': 'xxx.xx.xxx.x',
    'port': 12345,
    'user': 'user_name',
    'psw': 'your_password',
    'service': 'abc.xyz.com',
}

CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)

connection = cx_Oracle.connect(CONN_STR)

但是由于扫描IP没有计算机及其自己的用户名密码,我们该如何连接?

but as scan IP doesn not have machine and its own username passoword, How do we connect?

推荐答案

文档,您可以简单地使用tnsnames.ora中定义的名称.

Es described in the documentation, you can simple use the name defined in tnsnames.ora.

说您的RAC tnsnames条目称为MAXIMIR,您可以与其连接

Say your RAC tnsnames entry is called MAXIMIR than you can connect with

 con = cx_Oracle.connect("my_usr", "my_pwd", "MAXIMIR", encoding="UTF-8")

或者,您可以在dns变量中传递整个连接字符串

alternatively you may pass the whole connection string in a dns variable

dsn = """(DESCRIPTION=
             (FAILOVER=on)
             (ADDRESS_LIST=
               (ADDRESS=(PROTOCOL=tcp)(HOST=scan1)(PORT=1521))
               (ADDRESS=(PROTOCOL=tcp)(HOST=scan2)(PORT=1521)))
             (CONNECT_DATA=(SERVICE_NAME=MAXIMIR)))"""

connection = cx_Oracle.connect("my_usr", "my_pwd", dsn, encoding="UTF-8")

这篇关于如何使用python中的SCAN连接到Oracle-RAC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆