โ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
โ01-29-2024 01:32 PM
Any update?
โ01-29-2024 05:49 PM - edited โ01-29-2024 06:10 PM
Followed below steps to build the connection.
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:
โ01-29-2024 06:29 PM
Did you try any way using spark?
For example:
spark.read \
.format("jdbc") \
.option("url", url_file) \
Excited to expand your horizons with us? Click here to Register and begin your journey to success!
Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!