1

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)

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

TheBeginner
  • 405
  • 5
  • 23
  • 1
    You connect to a scan like you connect to any other non-RAC db. The scan uses virtual IPs so that they can be moved from one server to another in case the first one is down. The connection string is the same. – gsalem Dec 17 '19 at 09:01

1 Answers1

0

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

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")

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")
Marmite Bomber
  • 19,886
  • 4
  • 26
  • 53