How to fix: cx_Oracle.DatabaseError: ORA-12578: TNS:wallet open failed

I am establishing connection to Oracle database in Python using cx_Oracle. I am using wallet to connect to DB. And the code is running inside virtual env. When I activate the virtual env and run the script manually, it runs fine. But it throws below error when running form crontab or Tidal (a scheduler):

cx_Oracle.DatabaseError: ORA-12578: TNS:wallet open failed

Previously I was facing another similar issue:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so"

-working fine with manual run but gives error with crontab, which was resolved by including the suggested line from this answer.

Below is the cronjob:

0 6 * * * cd /path/to/the/code && /path/to/the/venv/myEnv/bin/python /path/script.py 

Below is the code:

#!/usr/bin/env python3
import os
import cx_Oracle
os.environ["ORACLE_HOME"]="/u01/app/oracle/product/12.2.0/client64"
def fetch_data(): #connection = cx_Oracle.connect("user", "pwd", "conn") connection = cx_Oracle.connect(dsn="WALLET_NAME", encoding="UTF-8") cursor = connection.cursor() with open('rtp_query.sql') as f: sql = f.read() cursor.execute(sql) result = cursor.fetchall() cursor.close() connection.close()

Note that username/pwd connection is working from both command line and crontab, but with Wallet string, it only works from command line, and throws below error for crontab:

cx_Oracle.DatabaseError: ORA-12578: TNS:wallet open failed
3

1 Answer

what helped on our end was to broaden permissions on the oracle wallet files. Locate your oracle wallet files and do 'chmod 750 *wallet*' so that other users of the same user group can read the files.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like