0

I'm trying to connect to the oracle database in python using cx_Oracle. But I'm stuck with the below error.

enter image description here

For reference my code

  def runQuery(self,query):
        with cx_Oracle.connect(config.username,config.password,config.dsn,encoding=config.encoding) as connection:
            try:
                print(connection.version)
            except cx_Oracle.Error as error:
                print(error)

Config File

username = 'dummy'
password = 'dummy'
dsn = 'dummy@//localhost:1521/ORCLCDB.localdomain'
port = 1512
encoding = 'UTF-8'

For additional knowledge, using the docker image of the oracle database for this purpose.

May I know how can clear the issue and proceed and could someone please help to find what is missing in my implementation.

3
  • This site has many similar questions, check your client version 32-bit or 64-bit, check LD_LIBRARY_PATH...Please try the suggestions first. Commented May 13, 2020 at 12:45
  • My client version is 64bit . How we can check LD_LIBRARY_PATH Commented May 13, 2020 at 12:48
  • Echo the LD_LIBRARY_PATH variable and see if it's pointing to the location where your instant client is installed. If not, export or set it based on your OS. Commented May 13, 2020 at 12:51

1 Answer 1

2

Do you have Oracle Instant Client installed? Looks like you are using Ubuntu. For an RPM-based distro, installation would look like this. There are instructions out there to install Oracle Instant Client on Ubuntu as well, but perhaps you are better of putting your Python code and cx_Oracle in a container as well, as Chris Jones explains here.

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

4 Comments

I'm developing the script in ubuntu. But I need to run the script in both ubuntu and window, How can implement the oracle connection in python irrespective of the operating system
Put everything in a container. See Chris Jones' blog posts
I can't use docker in the real scenario. Used it as ease for installing the oracle DB in Linux
Then you'll need to make sure the OS in question has cx_Oracle and Oracle Instant Client installed properly. Instructions for Windows are here .

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.