-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOracle_Write.py
More file actions
24 lines (17 loc) · 791 Bytes
/
Oracle_Write.py
File metadata and controls
24 lines (17 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from pyspark.sql import SparkSession
spark=SparkSession.builder.master("local").appName("SparkandOracledbTest").getOrCreate()
print("Start Reading Data from CSV")
df = spark.read.csv("test.csv", header=True, inferSchema=True)
print("Printing the Data from CSV .... ")
df.show()
print("Printing Schema of Data")
df.printSchema()
print("Start Writing Data to Oracle ...")
print("Creating Table ... ")
print("Table Creation Done")
df.write.format("jdbc").option("driver","oracle.jdbc.driver.OracleDriver")\
.option("url","jdbc:oracle:thin:@127.0.0.1:1521/XE")\
.option("user","simran")\
.option("password","sim").mode("overwrite").option("createTableOptions","")\
.option("dbtable","TEMP_DEP").save()
print("Writing Data to Oracle Completed Successfully .... !")