I am working on AWS Glue Python Shell. I want to connect python shell with Oracle. I am successful installing psycopg2 and mysql libraries but when I tried to connect Oracle using cx_Oracle, I have successfully installed the library but I am facing the error
DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory"
I have tried following things
I have downloaded
so
files from S3 and placed it in lib folder in parallel to the code fileI have set the LD_LIBRARY_PATH, ORACLE_HOME using os.environ
I am using following code
import boto3
import os
import sys
import site
from setuptools.command import easy_install
s3 = boto3.client('s3')
dir_path = os.path.dirname(os.path.realpath(__file__))
#os.path.dirname(sys.modules['__main__'].__file__)
install_path = os.environ['GLUE_INSTALLATION']
easy_install.main( ["--install-dir", install_path, "cx_Oracle"] )
importlib.reload(site)
import cx_Oracle
conn_str = u'{username}/{password}@{host}:{port}/{sid}'
conn = cx_Oracle.connect(conn_str)
c = conn.cursor()
c.execute(u'select * from hr.countries')
for row in c:
print(row[0], "-", row[1])
conn.close()
print('hello I am here');
I should be able to connect with oracle on aws glue python shell
os.environ()
is evaluated after the process starts, isn't it?LD_LIBRARY_PATH
needs to be set before it starts. – Christopher Jones