-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriteToDB.R
54 lines (41 loc) · 2.02 KB
/
writeToDB.R
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
53
sqlConnString <- "Driver=SQL Server;Server=MSI\\POLOYAYA;
Database=RevoTestDB;Uid=George;Pwd=george123"
sqlFraudTable <- "ccFraudSmall"
sqlRowsPerRead = 5000
# Connect to DB
sqlFraudDS <- RxSqlServerData(connectionString = sqlConnString,
table = sqlFraudTable, rowsPerRead = sqlRowsPerRead)
# Load the Sample Data
ccFraudCsv <- file.path(rxGetOption("sampleDataDir"),
"ccFraudSmall.csv")
# Define data type
inTextData <- RxTextData(file = ccFraudCsv,
colClasses = c(
"custID" = "integer", "gender" = "integer", "state" = "integer",
"cardholder" = "integer", "balance" = "integer",
"numTrans" = "integer",
"numIntlTrans" = "integer", "creditLine" = "integer",
"fraudRisk" = "integer"))
# wirte to DB
rxDataStep(inData = inTextData, outFile = sqlFraudDS, overwrite = TRUE)
#### wirte 2GB data to DB ####
sqlConnString <- "Driver=SQL Server;Server=MSI\\POLOYAYA;
Database=RevoTestDB;Uid=George;Pwd=george123"
sqlAirLineTable <- "airLineLarge"
sqlRowsPerRead = 40000
# Connect to DB
sqlAirLine <- RxSqlServerData(connectionString = sqlConnString,
table = sqlAirLineTable, rowsPerRead = sqlRowsPerRead)
# wirte XDF to DB
rxDataStep(inData = "D:/Download/AirOnTime87to12.xdf", outFile = sqlAirLine, overwrite = TRUE)
airLine <- rxReadXdf("D:/Download/AirOnTime87to12.xdf")
# Define data type
inTextData <- RxTextData(file = ccFraudCsv,
colClasses = c(
"custID" = "integer", "gender" = "integer", "state" = "integer",
"cardholder" = "integer", "balance" = "integer",
"numTrans" = "integer",
"numIntlTrans" = "integer", "creditLine" = "integer",
"fraudRisk" = "integer"))
# wirte to DB
rxDataStep(inData = inTextData, outFile = sqlFraudDS, overwrite = TRUE)