AWS Lambda cannot connect to Oracle Instant Client - python-3.x

I have a basic requirement of connecting an on premise Oracle database to Redshift.
I need to use AWS Lambda to connect to both the databases using python. While I achieved connection to Redshift by exporting Linux libraries of psycopg2, I am facing issues with the Oracle database.
Below are the steps followed to try to connect to Oracle on premise DB :
Installed cx_Oracle which came up with cx_Oracle.cpython-36m-x86_64-linux-gnu.so and psycopg2-2.7.4.dist-info
Installed basic oracle client lite 64 bit for linux
Set LD_LIBRARY_PATH to point to the lib files of the instant client package
When we zip our python file with the dependencies of cx_Oracle and Instant client, AWS Lambda fails with below error :
"DPI-1047: 64-bit Oracle Client library cannot be loaded: \"libclntsh.so: cannot open shared object file: No such file or directory\"

From within your lib folder, do:
ln -s libclntsh.so.12.1 libclntsh.so
(or similar, depending what versions you're using).

Related

How To access Cx_Oracle on Pivotal cloud factory (PCF)

I am trying to deploy my Python code where it involves usage of Oracle connection using cx_oracle module.
I referred the below link to set up my LD_LIBRARY_PATH
Deploy instant oracle on Pivotal CloudFoundry for cx_Oracle
export LD_LIBRARY_PATH=C:/Users/pm/Documents/project_1/oracle/instantclient_19_9:${LD_LIBRARY_PATH:-}
export OCI_LIB_DIR=C:/Users/pm/Documents/project_1/oracle/instantclient_19_9
export OCI_INC_DIR=C:/Users/pm/Documents/project_1/oracle/instantclient_19_9/sdk/include
Still facing same issue once code is pushed on to PCF.
[ERR] cx_Oracle.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 downloaded the oracle client zip file for windows 64bits 19.9 version.
And unzipped into the folder in my desktop path where my application is stored and used to push the code to pcf(C:/Users/pm/Documents/project_1/).
Could someone please guide me if any of the steps need modification and help me fix the issue.
On Windows the environment variable you want to manipulate is PATH. If that doesn't help, you can also use the environment variable DPI_DEBUG_LEVEL and set that to the value 64. That will show you all of the paths that are being tried.
You can see all of this in the installation manual.

Can't connect Excel to Oracle although I already installed the drivers. (Using Excel's PowerQuery)

I have been trying for a while now, to connect Excel to Oracle through PowerPivot, but unfortunately to no success.
I am currently getting this error: An error happened while reading data from the provider. 'Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.'.
I have so far done the following:
1. Installed Oracle Client x64
I installed Oracle Client x64 from https://www.oracle.com/database/technologies/112010-win64soft.html. I used file win64_11gR2_client.zip. In the installation proccess I went for the option InstantClient
2. Installed Oracle's ODBC Instant Client x64
I went to https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html and downloaded both instantclient-basic-windows.x64-19.6.0.0.0dbru.zip and instantclient-odbc-windows.x64-19.6.0.0.0dbru.zip. I 'installed' them by unziping them in the same folder, and running odbc_install.
Then, I added the directory to my path environment variables and then created a new one called TNS_ADMIN and added the same directory.
3. Installed Oracle's ODBC Instant Client x32
Finally I did the same for the x32 files, but I did not add that directory to my environment variables.
I validated the correct installation by finding the drivers here:
x64 Drivers:
x32 Drivers:
Help in Troubleshooting
It is frustrating that besides the error message I can't find any way to troubleshoot this issue. Any ideas on what could it be? Any ideas on how to troubleshoot?
Thanks!
With 32 bit Oracle Instant client
Option 1 with ODBC drivers
Option 2 without ODBC drivers and ODAC client
Option 1: After installing 32 bit odbc drivers try to add only 32 bit instant client to path or if you add both clients to system path make sure 32 bit client is above 64 bit client
If the order is set correctly in system path you can verify from command prompt with where command
C:\WINDOWS\system32>where sqlplus
D:\instantclient_19_6_x86\sqlplus.exe
D:\instantclient_19_6_x64\sqlplus.exe
or with command path
C:\WINDOWS\system32>path
PATH=D:\instantclient_19_6_x86;D:\instantclient_19_6_x64;xxxxx
If set correctly You can connect via odbc File--->From Other Sources --> From ODBC
Option 2: Enables you to connect to database via ODAC Client without ODBC driversFile--->From Database --> From Oracle Database
Download ODAC 32 bit from Oracle ODP.NET_Managed_ODAC122cR1.zip.
Unzip the folder and from elevated command prompt install
D:\ODP.NET_Managed_ODAC122cR1>install_odpm.bat D:\instantclient_19_6_x86 x86 true
Here I set target directory to 32 bit instant client i.e D:\instantclient_19_6_x86
Edit: Add tns name entry in tnsnames.ora and tns_admin system variable
i,e TNS_ADMIN= D:\instantclient_19_6_x86\network\admin

[unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so' : file not found

I have installed Postgresql 9.4 on Ubuntu 16.04, and installed postgresql ODBC and Unix ODBC drivers. When I test the ODBC connection with isql it works fine. Also, I am able to connect to the databases using pgadmin III from local and remote locations.
But, when I am trying to install a software which will create a connection using ODBC I am getting the following error
Connect failed!
Error code = -1
Status from database system is: STATE=01000, CODE=0, MSG=[unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so' : file not found
ERROR(-1)
But the library actually exists in this location. Please advise. I have attached the odbc.ini and odbcinst.ini for your reference.
file: /etc/odbc.ini
[PostgreSQL_DCTM]
Description=PostgreSQL DCTM
Driver=PostgreSQL_ANSI
Trace=No
TraceFile=/tmp/psqlodbc.log
Database=dctmdev
Servername=localhost
UserName=dctmdbadmin
Password=*******
Port=5432
Protocol=7.4-2
ReadOnly=No
RowVersioning=No
ShowSystemTables=No
ShowOidColumn=No
FakeOidIndex=No
UpdateableCursors=Yes
ConnSettings=
DEBUG=Yes
file: /etc/odbcinst.ini
[PostgreSQL_ANSI]
Description=PostgreSQL ODBC driver (ANSI version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=2
[PostgreSQL_Unicode]
Description=PostgreSQL ODBC driver (Unicode version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=2
Your help is much appreciated!
Update - 08/01/2018
/documentum/product/7.3/install/Server_Configuration_Program.bin: POSIX shell script executable (binary data)
/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e76dd2bbea2b741a14671866f35468af7c62acbb, stripped
The version of the psqlodbca.so is shown as 'stripped'. However, in the documentation of the software that I am trying to install it mentions to use 'not stripped' version. Could you please help me understand how could I procure the 'not stripped' version of the client library?
The problem was with the packaged libraries in the software that I was using to communicate to the database. After removing liblber-2.4.so.2 from the software lib, this started working.
For your reference, if any of you out there, is facing same problem while installing Opentext Documentum 7.3 on Ubuntu 16.04 and PostgreSQL 9.4, you might be hitting the same issue.

how to set oracle client library path in python when multiple oracle client version installed

i have 2 oracle client installed in linux machine. 10.2 and 12.2.
Second one i have to use for cx_oracle and older one is needed for other older implementation which i cant touch.
when i add second 12.2 oracle client library in LD_LIBRARY_PATH path and running simple oracle connection python program, it is giving me below error
cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 10.2 but must be at version 11.2 or higher
How can i use the newer version of client library without touching the old config?
Write a shell script that lists the 12.2 Oracle Client library in LD_LIBRARY_PATH before other Oracle libraries, and then invokes Python.
#!/bin/sh
export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
python "$#"

Can't open lib '/home/user/install/os410042/var/progress/DataDirect/Connect64_for_ODBC_71/lib/ddora27.so' : file not found

We have an application which works with oracle. Our application servers run in the Linux Platforms, and we have database servers running on the Windows machine. We are currently testing the new Progress ODBC driver to connect the Oracle DB from Linux server. So i have installed the DATA DIRECT PROGRESS ORACLE ODBC DRIVER, when i try to connect i got the below error
[unixODBC][Driver Manager]Can't open lib '/home/user/install/os410042/var/progress/DataDirect/Connect64_for_ODBC_71/lib/ddora27.so' : file not found
below is my ODBC.ini entry , and through isql i can able to connect to the Oracle Machine , but only my application is unable to connect.
[ODBC Data Sources]
Oracle Wire Protocol=DataDirect 7.1 Oracle Wire Protocol
ORACLE_TEST_DSN=DataDirect 7.1 Oracle Wire Protocol
[ODBC]
IANAAppCodePage=4
InstallDir=/home/user/install/os410042/var/progress/DataDirect/Connect64_for_ODBC_71
Trace=0
TraceFile=odbctrace.out
TraceDll=/home/user/install/os410042/var/progress/DataDirect/Connect64_for_ODBC_71/lib/ddtrc27.so
[ORACLE_TEST_DSN]
Driver=/home/user/install/os410042/var/progress/DataDirect/Connect64_for_ODBC_71/lib/ddora27.so
Description=DataDirect 7.1 Oracle Wire Protocol For Oracle
AlternateServers=
ApplicationUsingThreads=1
AccountingInfo=
Action=
ApplicationName=
ldd ddora27.so also fine , it doesnt show anything not found.
Run the DataDirect setup script to set variables: Two scripts, odbc.csh and odbc.sh, are installed in the installation directory. For Korn, Bourne, and equivalent shells, execute odbc.sh. For a C shell, execute odbc.csh. After running the setup script, execute the env command to verify that the ODBCHOME/lib directory has been added to your shared library path.
Link to related documentation.
An application restart may be required to pick up the new shared library path. Once the environment is configured, you'll be able to load the drivers.

Resources