0

I have to connect oracle database to extract data and write into pandas data frame.

All I have available with me is Hostname , Port, Service Name

import cx_Oracle
Hostname = 'XX.XX.X.XXX'
port = 1521
Service_Name = 'DPP2.kn.com'
dsn_tns = cx_Oracle.makedsn(Hostname, port, Service_Name)

connection = cx_Oracle.connect('BA', 'PASSWORD', dsn_tns)

Its not working.How to fix this

1
  • 2
    Have you installed the Instant client ( the oracle client driver) and set ORACLE_HOME to the appropriate path ? Commented Mar 30, 2019 at 17:36

1 Answer 1

1

You can use cx_Oracle.connect method as

dsn_tns = cx_Oracle.connect(username+"/"+password+"@"+ Hostname+":"+port+"/"+Service_Name)
cursor = dsn_tns.cursor()

and then retrieve data through cursor.execute()

Sign up to request clarification or add additional context in comments.

2 Comments

Getting database error DP1-1047 : Cannot locate a 64 bit Oracle client directory.
@pankaj the issue is obvious then ( 64-bit client needed )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.