I am trying to connect to my Oracle engine based RDS from lambda function and perform simple select queries.I have done the following:
- Downloaded instantclient-sdk-linux.x64-18.3.0.0.0dbru.zip and instantclient-basic-linux.x64-18.3.0.0.0dbru.zip
- Created the folder structure
~/lambda/lib
- Extracted the zip files in lib folder keeping the directory structure of zip files intact ( I am not sure if this is the right way to do it.)
- Downloaded the libaio1_0.3.110-5_amd64.deb file and extracted it to find two .xz files, extracted them too and got the
libaio.so.1
andlibaio.so.1.0.1
files. - Copied
libaio.so.1
from there to~/lambda/lib
- Created symbiolic link of
libaio.so.1
aslibaio.so
in~/lambda
usingln -s libaio.so.1.0.1 libaio.so
(But thelibaio.so
on opening writes that the link is broken, libaio.so.1.0.1 does not exist) - Installed
cx_Oracle
using pip in~/lambda
(pip install cx_Oracle -t .
) Lambda function named index.py (stored in
~/lambda
) is as follows:import os import json import cx_Oracle def handler(event, context): message = "" cursor = None connection = None
try: connection = cx_Oracle.connect("username", "password", "endpoint_of_rds_instance:port_no/ORCL") cursor = connection.cursor() cursor.execute("SELECT LOGIN-ID from USER_INFO where USER_ID=3972") except Exception as e: message += " {Error in connection} " + str(e) finally: if cursor: cursor.close() if connection: connection.close() return {'message' : message}Zipped it using
zip -r9 ~/upload.zip *
Not able to upload zip directly on as file size limit is 10 MB and this zip file is 96 MB. On using S3, it says the unzipped file size limit exceeded as my lambda folder is more than 200 MB in size.