cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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

Rishabh264
Honored Contributor II
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 .

Ajay-Pandey
Esteemed Contributor III

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

Kaniz
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/

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.