How to use Oracle Wallet to connect from databricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 09:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 01:32 PM
Any update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 05:49 PM - edited 01-29-2024 06:10 PM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 06:29 PM
Did you try any way using spark?
For example:
spark.read \
.format("jdbc") \
.option("url", url_file) \

