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 write dataframe to Oracle from Databricks ?

prasannar
New Contributor II
 
4 REPLIES 4

Rishabh-Pandey
Esteemed Contributor
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

Ajay-Pandey
Esteemed Contributor III

Hi @Prasanna Lakshmiโ€‹ you can use JDBC API to write the data.

Ajay Kumar Pandey

Kaniz_Fatma
Community Manager
Community Manager

Hi @Prasanna Lakshmiโ€‹, We havenโ€™t heard from you since the last response from @Ajay Pandeyโ€‹โ€‹ and @Rishabh Pandeyโ€‹, and I was checking back to see if their suggestions helped you.

Or else, If you have any solution, please share it with the community, as it can be helpful to others.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

sher
Valued Contributor II
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/

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