-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqldataload.py
More file actions
52 lines (41 loc) · 1.61 KB
/
Copy pathsqldataload.py
File metadata and controls
52 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Load to sql table, normal load
FactPurchasing.write.mode("overwrite").format("jdbc") \
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver") \
.option("truncate", "true") \
.option("url", jdbcUrl) \
.option("dbtable", "dbo.test2") \
.option("user", jdbcUsername) \
.option("batchsize","100000") \
.option("password", jdbcPassword).save()
# Load with spark bulk sql connector.
FactPurchasing.createOrReplaceTempView('testbulk')
%scala
import com.microsoft.azure.sqldb.spark.config.Config
import com.microsoft.azure.sqldb.spark.bulkcopy.BulkCopyMetadata
import com.microsoft.azure.sqldb.spark.connect._
val bulkCopyConfig = Config(Map(
"url" -> "ba-dev-asqlserver.database.windows.net",
"databaseName" -> "ba-dev-asqldb",
"user" -> "sql_user",
"password" -> "LaerdalTest#123",
"dbTable" -> "dbo.test2",
"bulkCopyBatchSize" -> "15000",
"bulkCopyTableLock" -> "true",
"bulkCopyTimeout" -> "600"
))
spark.table("testbulk").bulkCopyToSqlDB(bulkCopyConfig)
# df.bulkCopyToSqlDB(bulkCopyConfig, bulkCopyMetadata) if metadata is specified
# df.bulkCopyToSqlDB(bulkCopyConfig) if no metadata is specified.
#Print lists in Python (4 Different Ways)
#Printing a list in python can be done is following ways:
#Using for loop : Traverse from 0 to len(list) and print all elements of the list one by one uisng a for loop, this is the standard practice of doing it.
#filter_none
#edit
#play_arrow
#brightness_4
# Python program to print list
# using for loop
a = [1, 2, 3, 4, 5]
# printing the list using loop
for x in range(len(a)):
print a[x],