Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA: 12154 error while connecting to Oracle 11g database using python 3.6

user9336373Sep 5 2017 — edited Sep 5 2017

import cx_Oracle

print('connection start')

db_connection = cx_Oracle.connect("jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <Host1>)(PORT = <port_number>)) (ADDRESS = (PROTOCOL = TCP)(HOST = <Host2>)(PORT = <port_number>)) (FAILOVER=true)(LOAD_BALANCE=true) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = <service_name>) (FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180)(DELAY=5))))", "<username>", "<password>")

print(db_connection)

print('connection successful')

I'm trying to connect to Oracle 11g database using the above python 3.6 code. However, I'm encountering the following error.

DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

I'm able to successfully connect to same oracle 11g database by using Oracle-SQL-Developer version 17 (with the same connection string).

So, I'm wondering if there is any issue with my code or does cx_Oracle needs supporting drivers etc. Any help would be much appreciated.

This post has been answered by Anthony Tuininga-Oracle on Sep 5 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2017
Added on Sep 5 2017
3 comments
17,216 views