-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathODBC.r
53 lines (33 loc) · 1.39 KB
/
ODBC.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
library("RODBC")
sqlHost <- "MSI\\POLOYAYA"
sqlDatabase <- "RevoTestDB"
sqlUser <- "George"
sqlPw <- "george123"
# Define SQL Server connection string ----------------
dsn <- sprintf("Driver=SQL Server;Server=%s;Database=%s;Uid=%s;Pwd=%s;",
sqlHost, sqlDatabase, sqlUser, sqlPw)
channel <- odbcDriverConnect(dsn)
#### small Data Set ####
Start <- Sys.time()
SqlData <- sqlQuery(channel,paste("select * from [RevoTestDB].[db_datareader].[AirlineDemoSmall] "))
model.lm <- lm(ArrDelay ~ CRSDepTime + DayOfWeek - 1, SqlData)
#system.time(model.lm <- lm(ArrDelay ~ CRSDepTime + DayOfWeek - 1, myData))
Sys.time() - Start
odbcClose(channel)
##################################################################################
library(RODBC)
sqlHost <- "MSI\\POLOYAYA"
sqlDatabase <- "Master" #"RevoTestDB"
sqlUser <- "" #"George"
sqlPw <- "" #"george123"
# Define SQL Server connection string ----------------
dsn <- sprintf("Driver=SQL Server;Server=%s;Database=%s;Uid=%s;Pwd=%s;",
sqlHost, sqlDatabase, sqlUser, sqlPw)
channel <- odbcDriverConnect(dsn)
#### Large Data Set ####
Start <- Sys.time()
SqlData <- sqlQuery(channel,paste("select * from [AirlineLarge]"))
model.lm <- lm(ArrDelay ~ CRSDepTime + DayOfWeek - 1, SqlData)
#system.time(model.lm <- lm(ArrDelay ~ CRSDepTime + DayOfWeek - 1, myData))
Sys.time() - Start
odbcClose(channel)