How to write dataframe to Oracle from Databricks ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 10:08 PM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 10:40 PM
sql = "select * from tablename"
user = ""
password = ""
server = ""
port =
service_name = ''
jdbcUrl = f"jdbc:oracle:thin:@{server}:{port}:{service_name}"
jdbcDriver = "oracle.jdbc.driver.OracleDriver"
DF = spark.read.format("jdbc") \
.option("url", jdbcUrl) \
.option("query", sql) \
.option("user", user) \
.option("password", password) \
.option("driver", jdbcDriver) \
.load()
by this you can make a connection with your oracle database and read files from the database and same you can write the data to particular database .
Rishabh Pandey
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 11:09 PM
Hi @Prasanna Lakshmi you can use JDBC API to write the data.
Ajay Kumar Pandey
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 09:52 PM
Df.write.format('jdbc').options(
url='jdbc:oracle:thin:@192.168.11.100:1521:ORCL',
driver='oracle.jdbc.driver.OracleDriver',
dbtable='testschema.test',
user='testschema',
password='password').mode('overwrite').save()try this. refer link: https://dwgeek.com/load-spark-dataframe-to-oracle-table-example.html/