pythonoracle-cloud-infrastructureoracle-autonomous-db

How to access OCI ADW without wallet from OCI Datascience notebook(Python)


I have created Autonomous Data Warehouse in OCI and trying to access it from OCI Data science notebooks by following this docs Connect Python without a Wallet

I have also installed Oracle Instant Client 19.6 and added symlink as mentioned in above doc but the script is looking for wallet file and throws error: ORA-28759: failure to open file

Code:

import cx_Oracle as cx
import sys

dsn = """(description= (retry_count=15)(retry_delay=3)(address=(protocol=tcps)
<my-connection-string> C=US")))"""

try:
    con = cx.connect(user="<my-user>", password="<my-password>", dsn=dsn, encoding="UTF-8")
    print("Database version:", con.version)
except Exception as err:
    print(err)
    sys.exit(1)

Yes, I've checked other related questions but no luck! Thanks in advance.


Solution

  • With the cx_Oracle driver you need Instant Client 19.14 (or later), or 21.5 (or later). The 1-way TLS support was added to this version.

    With the newest release of the driver, which got renamed python-oracledb (see the release announcement), you only need Instant Client if you want to use the 'Thick' mode. By default, the Thin mode is used and it can connect to ADW with, or without, wallets.

    If you have a sqlnet.ora file from a previous use of mTLS, then you should remove it: it's likely you have one and the wallet location in that file is being looked up and giving you the error.

    Then follow the doc or the new blog Easy wallet-less connections to Oracle Autonomous Databases in Python

    (Yes technically the feature is useable with the recut 19.13 Instant Client on Linux as noted in the doc, but that is now superseded and the feature is available on more architectures from 19.14 and 21.5 onward)