cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to use Oracle Wallet to connect from databricks

RKNutalapati
Valued Contributor

How to onnect Databricks to Oracle DAS / Autonomous Database using a cloud wallet, What are the typical steps and best practices to follow. Appreciate an example code snippet for connecting to the above data source

3 REPLIES 3

heeiow
New Contributor II

Any update?

RKNutalapati
Valued Contributor

 Followed below steps to build the connection.

  1. Unzip Oracle Wallet objects and copy them to a secure location accessible by your Databricks workspace.
  2. Collaborate with your Network team and Oracle Autonomous Instance Admins to open firewalls between your workspace to connect and retreive data..
  3. Install Python oracledb library. (2. Installing python-oracledb โ€” python-oracledb 2.0.1 documentation)
  4. 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...

 

 

heeiow
New Contributor II

Did you try any way using spark?

For example:

spark.read \
.format("jdbc") \
.option("url", url_file) \

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.