Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Rman Notes -1 Oracle
  • Find Time Consuming SQL Statements in Oracle 10g Oracle
  • 556976.1 Oracle Clusterware: Components installed Oracle
  • Sample WW22 listener.ora Oracle
  • Find_planinfo.sql Oracle
  • Drop database in Oracle 10g Oracle
  • My Minimum Tuning Programs Oracle
  • Oracle Metalink useful notes Oracle
  • Histogram information Oracle
  • metalink all dynamic view reference notes. Oracle
  • backspace in SQL Plus not working then..? Linux/Unix
  • ORA-3136 Oracle
  • create database link syntax Oracle
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • Find_table_size.sql Oracle

How to connect to Oracle Database with Wallet with Python.

Posted on 21-Mar-2025 By Admin No Comments on How to connect to Oracle Database with Wallet with Python.

To connect Python to Oracle Database using an Oracle Wallet, you can use the cx_Oracle or oracledb library with Oracle Client libraries (like Oracle Instant Client). Oracle Wallet simplifies secure connections by storing credentials and SSL certificates.


✅ Steps to Connect Python to Oracle using Oracle Wallet


Step 1: Install Required Python Package

pip install oracledb
  • Prefer oracledb (official Oracle-supported replacement for cx_Oracle).
  • Compatible with Oracle Wallet and works in both thin and thick modes.

Step 2: Install Oracle Instant Client

  • Download from Oracle Instant Client Downloads
  • Extract it to a known location (e.g., C:\oracle\instantclient_19_11 or /opt/oracle/instantclient_19_11)
  • Add the path to your system environment:

Linux/macOS:

export LD_LIBRARY_PATH=/path/to/instantclient:$LD_LIBRARY_PATH

Windows (Command Prompt):

set PATH=C:\oracle\instantclient_19_11;%PATH%

Step 3: Create or Use an Oracle Wallet

  • Oracle Wallet typically resides under:
    network/admin folder inside the Oracle Client path.
  • Your folder should contain:
    • sqlnet.ora
    • tnsnames.ora
    • cwallet.sso

Example sqlnet.ora:

WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = /path/to/wallet)))
SQLNET.WALLET_OVERRIDE = TRUE
SSL_SERVER_DN_MATCH = yes

Example tnsnames.ora:

MYDB_ALIAS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCPS)(HOST = your_host)(PORT = 2484))
    (CONNECT_DATA = (SERVICE_NAME = your_service))
    (SECURITY = (SSL_SERVER_CERT_DN = "CN=your_cert"))
  )

Step 4: Python Code to Connect

import oracledb

# Optional: Switch to thick mode to use Oracle Wallet
oracledb.init_oracle_client(lib_dir="/path/to/instantclient")

# Use tns alias defined in tnsnames.ora
conn = oracledb.connect(dsn="MYDB_ALIAS")

# Use the connection
cursor = conn.cursor()
cursor.execute("SELECT * FROM dual")
for row in cursor:
    print(row)

cursor.close()
conn.close()

✅ If the wallet contains credentials, you don’t need to provide user and password.


🧪 Quick Checklist

ItemRequiredExample
Oracle Instant Client✅instantclient_19_11
Oracle Wallet files✅cwallet.sso, sqlnet.ora, etc.
tnsnames.ora entry✅MYDB_ALIAS = ...
Python library (oracledb)✅pip install oracledb
init_oracle_client()✅For thick mode

Would you like help writing a sample sqlnet.ora and tnsnames.ora for your setup? Or are you facing a specific error?

Oracle, Python/PySpark

Post navigation

Previous Post: JSON/XML Types in Oracle
Next Post: SQL Tracker by SID sqltrackerbysid.sql

Related Posts

  • Load testing on Oracle 19C RAC with HammerDB Oracle
  • Composite Index creation tip from Vivek Oracle
  • Difference between SYNC and AFFIRM Oracle
  • ORA-4031 issue and solution on 09-MAY-2008 Oracle
  • Important Script Method for tuning Oracle
  • Find execution plan from dba_hist_sql_plan for a specific SQL_ID and PLAN_HASH_VALUE fplan.sql Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (399)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (347)
  • SQL Server (6)
  • Uncategorized (3)
  • Videos (0)

Recent Posts

  • find_arc.sql09-Apr-2026
  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026
  • Creating a Container Database using dbaascli08-Apr-2026
  • track_autoupgrade_copy_progress.sql01-Apr-2026
  • refre.sql for multitenant01-Apr-2026
  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • crtgr.sql /* For creating trigger from data dictionary */ Oracle
  • To see mem usage and CPU usage system wide. Linux/Unix
  • Drop tempfiles from database Oracle
  • Some OS level threshold for performance. Linux/Unix
  • Does DBMS_JOB recompute the NEXT_DATE interval after or before Oracle
  • oracle 10g on linux Linux/Unix
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • Rman Notes -1 Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme