0

I have a task to connect to an AWS RDS Oracle server and retrieve information using lambda layer. I have been working on this issue for almost two days. I discovered a lightweight Oracle database installation called python-oracledb but haven't been able to resolve the problem. I need help.

I am using Windows on my local machine, and the Oracle RDS is on a Windows EC2 instance as well.

Here is the error I am encountering:

`
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'oracledb'
Traceback (most recent call last)
RequestId: 87f11785-14c0-4a8c-8dbf-61be98995b82
REPORT RequestId: 87f11785-14c0-4a8c-8dbf-61be98995b82 Duration: 3.22 ms Billed Duration: 4 ms Memory Size: 128 MB Max Memory Used: 61 MB Init Duration: 255.42 ms
`

I have referred to both ChatGPT, stackoverflow and Oracle documentation on using oracle-db, but I keep encountering the same error. I also attempted to use cx_oracle with the Oracle client, but I faced errors and size limitations when uploading it as a Lambda layer.

Steps I have taken:

Created a directory for the lambda layer:

`mkdir lambda_layer
cd lambda_layer
mkdir python`

Installed the oracledb package:

`pip install oracledb -t ./python`

Created a zip file for the layer:

cd python
zip -r ../python_oracledb_layer.zip .

I uploaded the python_oracledb_layer.zip file and ensured I used Python 3.12, which was used for local compilation (I've also tried other runtime versions). However, I still encounter the same error.

enter image description here

oracledb folder enter image description here

10
  • Probable duplicate of stackoverflow.com/questions/17309288/… (different module but the same principle still applies - you need to install the module, using pip install, so python can use it). Commented Jun 17, 2024 at 8:54
  • Please edit the question to include a minimal reproducible example with details of: the contents of the layer zip file including the install.sh script and/or how you create the python site_packages directory within the zip file. Commented Jun 17, 2024 at 9:24
  • @MT0 I do not understand what you mean how I created the site_packages, but I do note that the site_packages are in appdata\lib\...... which might already be preinstalled. I have included the screenshot and where is the install.sh Is there any step am missing? Commented Jun 17, 2024 at 9:30
  • 1
    The documentation for layers is here and this part of the documentation discusses site_packages (which you would use if you were including the python module in the zip file rather than pip installing it). There are sample layers here and here. Commented Jun 17, 2024 at 9:38
  • 1
    Does github.com/aws-samples/aws-lambda-python-oracle-connection help? Commented Jun 17, 2024 at 22:55

0

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.