cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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) \

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group