Followed below steps to build the connection.
- Unzip Oracle Wallet objects and copy them to a secure location accessible by your Databricks workspace.
- Collaborate with your Network team and Oracle Autonomous Instance Admins to open firewalls between your workspace to connect and retreive data..
- Install Python oracledb library. (2. Installing python-oracledb โ python-oracledb 2.0.1 documentation)
- Code Snippet
 
 
 
import oracledb
con = oracledb.connect(user='<YOUR USER_NAME>',
                       password='<YOUR PASSWORD>',
                       dsn='<Network Service Name>',  #Refer tnsnames.ora   
                       config_dir='<WALLET FOLDER PATH>',
                       wallet_location="<WALLET FOLDER PATH>"
                       wallet_password="<PASSWORD>"
                     )
# Create a cursor
cursor = con.cursor()
# Execute a query
query = 'SELECT * FROM <Schema>.<TableName>'
cursor.execute(query)
# Fetch results
results = cursor.fetchall()
for row in results:
 print(row)
# Close cursor and connection
cursor.close()
con.close()
 
Other references:
https://blogs.oracle.com/opal/post/easy-way-to-connect-python-applications-to-oracle-autonomous-data...
https://medium.com/@laurent.leturgez/how-to-bring-your-oracle-autonomous-database-data-into-the-lake...