Abhishek
Abhishek

Reputation: 41

Getting an error (DPI-1047) while connecting to Oracle RDS with AWS Lambda

I'm using an AWS Lambda function (in Python) to connect to an Oracle database (RDS) using cx_Oracle library. But it is giving me the below error - "DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory".

Steps I've followed -

  1. Created a python virtual environment and downloaded the cx_Oracle library on an EC2 instance.
  2. Uploaded the downloaded library on S3 bucket and created a Lambda Layer with it
  3. Used this layer in the Lambda function to connect to the Oracle RDS
  4. Used below command to connect to the DB -

conn = cx_Oracle.connect(user="user-name", password="password", dsn="DB-Endpoint:1521/"database-name",encoding="UTF-8")

Please help me in resolving this issue.

Upvotes: 0

Views: 594

Answers (2)

Abhishek
Abhishek

Reputation: 41

The reason I faced this issue was that I just downloaded cx_Oracle library. In order to connect to the Oracle database from the Lambda function, we need to download the Oracle client and libaio libraries as well and club them with cx_Oracle to create a Lambda Layer. Once I followed these steps, I was able to connect to the Oracle database and query its tables. I've created a video for this process, so that others need not go through the issues I faced. Hope it will be helpful to all - https://youtu.be/BYiueNog-TI

Upvotes: 0

Anthony Tuininga
Anthony Tuininga

Reputation: 7086

Set the environment variable DPI_DEBUG_LEVEL to the value 64 and then rerun your code. The debugging output should help you figure out what is being searched. Note that you need to have the 64-bit instant client installed as well!

Upvotes: 1

Related Questions