Skip to content

Commit

Permalink
switching reads to odbc package
Browse files Browse the repository at this point in the history
checking results are the same
  • Loading branch information
wibeasley committed Jan 4, 2018
1 parent 5eaf6b6 commit e848104
Show file tree
Hide file tree
Showing 9 changed files with 3,336 additions and 3,341 deletions.
17 changes: 9 additions & 8 deletions analysis/archive-ace/archive-ace.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ source("./utility/connectivity.R")

# ---- load-packages -----------------------------------------------------------
library(NlsyLinks) # devtools::install_github("LiveOak/NlsyLinks")
library(RODBC)
# library(RODBC)
library(ggplot2)
library(colorspace)
library(xtable)
library(plyr)

requireNamespace("odbc")

# ---- declare-globals ---------------------------------------------------------
#Define CSV of outcomes/phenotypes
pathInput <- "./ForDistribution/Outcomes/ExtraOutcomes79.csv"
Expand Down Expand Up @@ -97,17 +99,16 @@ sql <- paste("
# WHERE Process.tblRelatedStructure.RelationshipPath = ", relationshipPath, "
# AND (Process.tblRelatedValuesArchive.AlgorithmVersion IN (73, 75))")

sqlDescription <- "SELECT * FROM Archive.tblArchiveDescription" #AlgorithmVersion, Description
# sqlDescription <- "SELECT AlgorithmVersion, Description, Date2 FROM Archive.tblArchiveDescription where AlgorithmVersion=72" #AlgorithmVersion, Description
sqlDescription <- "SELECT AlgorithmVersion, Description FROM Archive.tblArchiveDescription" #AlgorithmVersion, Description

# ---- load-data ---------------------------------------------------------------
channel <- open_dsn_channel()

startTime <- Sys.time()
channel <- open_dsn_channel_odbc()
# odbcGetInfo(channel)

dsRaw <- sqlQuery(channel, sql, stringsAsFactors=F)
dsDescription <- sqlQuery(channel, sqlDescription, stringsAsFactors=F)
odbcClose(channel)
dsRaw <- DBI::dbGetQuery(channel, sql)
dsDescription <- DBI::dbGetQuery(channel, sqlDescription)
DBI::dbDisconnect(channel, sql, sqlDescription)
elapsedTime <- Sys.time() - startTime
# print(elapsedTime)
# nrow(dsRaw)
Expand Down
32 changes: 9 additions & 23 deletions analysis/archive-comparison/archive-comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,18 @@ sql <- paste("


# sql <- gsub(pattern="\\n", replacement=" ", sql)
sqlDescription <- "SELECT * FROM Archive.tblArchiveDescription" #AlgorithmVersion, Description
# sqlDescription <- "SELECT AlgorithmVersion, Description, Date2 FROM Archive.tblArchiveDescription where AlgorithmVersion=72" #AlgorithmVersion, Description
sqlDescription <- "SELECT AlgorithmVersion, Description FROM Archive.tblArchiveDescription" #AlgorithmVersion, Description
startTime <- Sys.time()

# ---- load-data ---------------------------------------------------------------
# channel <- RODBC::odbcDriverConnect("driver={SQL Server};Server=Bee\\Bass; Database=NlsLinks; Uid=NlsyReadWrite; Pwd=nophi")
channel <- RODBC::odbcDriverConnect("driver={SQL Server};Server=192.168.1.66\\Express_2016; Database=NlsLinks; Uid=NlsyReadWrite; Pwd=nophi")

channel <- RODBC::odbcDriverConnect("Driver={ODBC Driver 13 for SQL Server};Server=192.168.1.66\\Express_2016; Uid=NlsyReadWrite; Pwd=nophi" )

conn <- DBI::dbConnect(
RSQLServer::SQLServer(),
# "Server=gimble\\Express_2016",
# "Server=192.168.1.66\\Express_2016",
"192.168.1.66\\Express_2016",
"user=NlsyReadWrite; Password=nophi",
database = "NlsLinks"
)


channel <- open_dsn_channel()
odbcGetInfo(channel)

dsRaw <- sqlQuery(channel, sql, stringsAsFactors=F)
dsDescription <- sqlQuery(channel, sqlDescription, stringsAsFactors=F)

RODBC::odbcClose(channel); rm(channel, sql, sqlDescription)
startTime <- Sys.time()
channel <- open_dsn_channel_odbc()
# DBI::dbGetInfo(channel)
dsRaw <- DBI::dbGetQuery(channel, sql)
dsDescription <- DBI::dbGetQuery(channel, sqlDescription)
DBI::dbDisconnect(channel, sql, sqlDescription)
elapsedTime <- Sys.time() - startTime
(Sys.time() - startTime); rm(startTime)
nrow(dsRaw)

Expand Down
Binary file modified analysis/archive-comparison/archive-comparison.pdf
Binary file not shown.
28 changes: 12 additions & 16 deletions analysis/archive-comparison/archive-comparison.tex
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@
\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{verbatim}
## DBMS_Name DBMS_Ver Driver_ODBC_Ver Data_Source_Name
## "Microsoft SQL Server" "13.00.4206" "03.80" "local-nlsy-links"
## Driver_Name Driver_Ver ODBC_Ver Server_Name
## "msodbcsql13.dll" "14.00.0500" "03.80.0000" "GIMBLE\\EXPRESS_2016"
## Time difference of 0.8384829 secs
## Time difference of 0.4893291 secs
## [1] 22176
\end{verbatim}
\end{kframe}
Expand Down Expand Up @@ -125,8 +121,8 @@
\caption{ROC for Gen1Housemates (left) and Gen2Siblings (right)}
\end{figure}

% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Sep 14 17:11:54 2017
% latex table generated in R 3.4.3 by xtable 1.8-2 package
% Thu Jan 04 10:42:50 2018
\begin{table}[ht]
\centering
\begingroup\large
Expand All @@ -140,8 +136,8 @@
\endgroup
\caption{Counts for Gen1Housemates}
\end{table}
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Sep 14 17:11:54 2017
% latex table generated in R 3.4.3 by xtable 1.8-2 package
% Thu Jan 04 10:42:51 2018
\begin{table}[ht]
\centering
\begingroup\large
Expand All @@ -155,8 +151,8 @@
\endgroup
\caption{Counts for Gen1Housemates (Previous version of links)}
\end{table}
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Sep 14 17:11:54 2017
% latex table generated in R 3.4.3 by xtable 1.8-2 package
% Thu Jan 04 10:42:51 2018
\begin{table}[ht]
\centering
\begingroup\large
Expand All @@ -175,8 +171,8 @@
\endgroup
\caption{Counts for Gen2Siblings}
\end{table}
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Sep 14 17:11:54 2017
% latex table generated in R 3.4.3 by xtable 1.8-2 package
% Thu Jan 04 10:42:51 2018
\begin{table}[ht]
\centering
\begingroup\large
Expand All @@ -197,11 +193,11 @@
\end{table}


% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Sep 14 17:11:54 2017
% latex table generated in R 3.4.3 by xtable 1.8-2 package
% Thu Jan 04 10:42:51 2018
\begin{table}[ht]
\centering
\begin{tabular}{rrrrlr}
\begin{tabular}{rrrrrr}
\hline
Count & RImplicit2004 & RImplicit & RExplicit & RRoster & Delta \\
\rowcolor{goodColor} \hline
Expand Down
Binary file modified analysis/archive-comparison/figure/unnamed-chunk-2-1.pdf
Binary file not shown.
Binary file modified analysis/archive-comparison/figure/unnamed-chunk-2-2.pdf
Binary file not shown.
10 changes: 5 additions & 5 deletions analysis/eda/counts/counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source("./utility/connectivity.R")
# ---- load-packages -----------------------------------------------------------
library(magrittr) #Pipes
# library(ggplot2) #For graphing
requireNamespace("RODBC")
requireNamespace("odbc")
requireNamespace("dplyr")
requireNamespace("scales") #For formating values in graphs
requireNamespace("knitr") #For the kable function for tables
Expand Down Expand Up @@ -53,10 +53,10 @@ sql_variable <- "
# ---- load-data ---------------------------------------------------------------
ds <- database_inventory()

channel <- open_dsn_channel_rodbc()
ds_item <- RODBC::sqlQuery(channel, sql_item , stringsAsFactors=F)
ds_variable <- RODBC::sqlQuery(channel, sql_variable, stringsAsFactors=F)
RODBC::odbcClose(channel); rm(channel, sql_item, sql_variable)
channel <- open_dsn_channel_odbc()
ds_item <- DBI::dbGetQuery(channel, sql_item )
ds_variable <- DBI::dbGetQuery(channel, sql_variable)
DBI::dbDisconnect(channel); rm(channel, sql_item, sql_variable)

# ---- tweak-data --------------------------------------------------------------
ds_pretty <- ds %>%
Expand Down
Loading

0 comments on commit e848104

Please sign in to comment.