From 5eaf6b6e94ee6cd55083ada0c380810c8d30bc17 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 4 Jan 2018 01:36:05 -0600 Subject: [PATCH] import stitch md --- dal/import-79-metadata.R | 2 +- dal/import-79-raw.R | 2 +- stitched-output/dal/import-metadata.html | 837 +++++++++++++---------- stitched-output/dal/import-metadata.md | 837 +++++++++++++---------- stitched-output/dal/import-raw.html | 313 ++++----- stitched-output/dal/import-raw.md | 320 ++++----- 6 files changed, 1271 insertions(+), 1040 deletions(-) diff --git a/dal/import-79-metadata.R b/dal/import-79-metadata.R index d3fccda..f1be9c8 100644 --- a/dal/import-79-metadata.R +++ b/dal/import-79-metadata.R @@ -1,4 +1,4 @@ -# knitr::stitch_rmd(script="./dal/import-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T) +# knitr::stitch_rmd(script="./dal/import-79-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T) rm(list=ls(all=TRUE)) #Clear the variables from previous runs. # ---- load-sources ------------------------------------------------------------ diff --git a/dal/import-79-raw.R b/dal/import-79-raw.R index ba1e42d..9771298 100644 --- a/dal/import-79-raw.R +++ b/dal/import-79-raw.R @@ -1,4 +1,4 @@ -# knitr::stitch_rmd(script="./dal/import-raw.R", output="./stitched-output/dal/import-raw.md") # dir.create(output="./stitched-output/dal/", recursive=T) +# knitr::stitch_rmd(script="./dal/import-79-raw.R", output="./stitched-output/dal/import-raw.md") # dir.create(output="./stitched-output/dal/", recursive=T) rm(list=ls(all=TRUE)) #Clear the variables from previous runs. # ---- load-sources ------------------------------------------------------------ diff --git a/stitched-output/dal/import-metadata.html b/stitched-output/dal/import-metadata.html index 1f17b4d..295dc77 100644 --- a/stitched-output/dal/import-metadata.html +++ b/stitched-output/dal/import-metadata.html @@ -202,9 +202,9 @@

This report was automatically generated with the R package knitr -(version 1.17).

+(version 1.18).

-
# knitr::stitch_rmd(script="./dal/import-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T)
+
# knitr::stitch_rmd(script="./dal/import-79-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T)
 rm(list=ls(all=TRUE))  #Clear the variables from previous runs.
 
@@ -223,10 +223,11 @@ requireNamespace("dplyr" ) #Avoid attaching dplyr, b/c its function names conflict with a lot of packages (esp base, stats, and plyr). requireNamespace("testit" ) #For asserting conditions meet expected patterns. requireNamespace("RODBC" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. +requireNamespace("odbc" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk.
# Constant values that won't change.
-directory_in              <- "data-public/metadata/tables"
+directory_in              <- "data-public/metadata/tables-79"
 
 col_types_minimal <- readr::cols_only(
   ID                                  = readr::col_integer(),
@@ -239,7 +240,7 @@
 #   - Tables are WRITTEN from top to bottom.
 #   - Tables are DELETED from bottom to top.
 lst_col_types <- list(
-  Item = readr::cols_only(
+  item = readr::cols_only(
     ID                                  = readr::col_integer(),
     Label                               = readr::col_character(),
     MinValue                            = readr::col_integer(),
@@ -248,6 +249,15 @@
     Active                              = readr::col_logical(),
     Notes                               = readr::col_character()
   ),
+  # item_97 = readr::cols_only(
+  #   ID                                  = readr::col_integer(),
+  #   Label                               = readr::col_character(),
+  #   MinValue                            = readr::col_integer(),
+  #   MinNonnegative                      = readr::col_integer(),
+  #   MaxValue                            = readr::col_integer(),
+  #   Active                              = readr::col_logical(),
+  #   Notes                               = readr::col_character()
+  # ),
   LUExtractSource = col_types_minimal,
   LUMarkerEvidence = col_types_minimal,
   LUMarkerType = readr::cols_only(
@@ -319,8 +329,8 @@
     ResponseLowerLabel                  = readr::col_character(),
     ResponseUpperLabel                  = readr::col_character()
   ),
-  Variable = readr::cols_only(
-    ID                                  = readr::col_integer(),
+  variable = readr::cols_only(
+    # ID                                  = readr::col_integer(),
     VariableCode                        = readr::col_character(),
     Item                                = readr::col_integer(),
     Generation                          = readr::col_integer(),
@@ -330,9 +340,22 @@
     LoopIndex                           = readr::col_integer(),
     Translate                           = readr::col_integer(),
     Notes                               = readr::col_character(),
-    Active                              = readr::col_logical(),
+    Active                              = readr::col_integer(),
     Notes                               = readr::col_character()
   )
+  # variable_97 = readr::cols_only(
+  #   # ID                                  = readr::col_integer(),
+  #   VariableCode                        = readr::col_character(),
+  #   Item                                = readr::col_integer(),
+  #   Generation                          = readr::col_integer(),
+  #   ExtractSource                       = readr::col_integer(),
+  #   SurveySource                        = readr::col_integer(),
+  #   SurveyYear                          = readr::col_integer(),
+  #   LoopIndex                           = readr::col_integer(),
+  #   Translate                           = readr::col_integer(),
+  #   Active                              = readr::col_integer(),
+  #   Notes                               = readr::col_character()
+  # )
 )
 
 col_types_mapping <- readr::cols_only(
@@ -349,25 +372,26 @@
 ds_mapping
 
-
## # A tibble: 15 x 5
-##              table_name schema_name        enum_name c_sharp_type
-##                   <chr>       <chr>            <chr>        <chr>
-##  1                 Item    Metadata             Item        short
-##  2      LUExtractSource        Enum    ExtractSource         byte
-##  3             LUGender        Enum           Gender         byte
-##  4     LUMarkerEvidence        Enum   MarkerEvidence         byte
-##  5         LUMarkerType        Enum       MarkerType         byte
-##  6      LUMultipleBirth        Enum    MultipleBirth         byte
-##  7         LURaceCohort        Enum       RaceCohort         byte
-##  8   LURelationshipPath        Enum RelationshipPath         byte
-##  9         LURosterGen1        Enum       RosterGen1        short
-## 10       LUSurveySource        Enum     SurveySource         byte
-## 11           LUTristate        Enum         Tristate         byte
-## 12              LUYesNo        Enum            YesNo        short
-## 13             MzManual    Metadata     NA_character NA_character
-## 14 RosterGen1Assignment    Metadata     NA_character NA_character
-## 15             Variable    Metadata     NA_character NA_character
-## # ... with 1 more variables: convert_to_enum <lgl>
+
## # A tibble: 17 x 5
+##    table_name           schema_name enum_name        c_sharp_type convert~
+##    <chr>                <chr>       <chr>            <chr>        <lgl>   
+##  1 item                 Metadata    item             short        T       
+##  2 #item_97             Metadata    item_97          short        T       
+##  3 LUExtractSource      Enum        ExtractSource    byte         T       
+##  4 LUGender             Enum        Gender           byte         T       
+##  5 LUMarkerEvidence     Enum        MarkerEvidence   byte         T       
+##  6 LUMarkerType         Enum        MarkerType       byte         T       
+##  7 LUMultipleBirth      Enum        MultipleBirth    byte         T       
+##  8 LURaceCohort         Enum        RaceCohort       byte         T       
+##  9 LURelationshipPath   Enum        RelationshipPath byte         T       
+## 10 LURosterGen1         Enum        RosterGen1       short        T       
+## 11 LUSurveySource       Enum        SurveySource     byte         T       
+## 12 LUTristate           Enum        Tristate         byte         T       
+## 13 LUYesNo              Enum        YesNo            short        T       
+## 14 MzManual             Metadata    NA_character     NA_character F       
+## 15 RosterGen1Assignment Metadata    NA_character     NA_character F       
+## 16 variable             Metadata    NA_character     NA_character F       
+## 17 #variable_97         Metadata    NA_character     NA_character F
 
ds_file <- lst_col_types %>%
@@ -382,56 +406,57 @@
 
## # A tibble: 14 x 4
-##                    name
-##                   <chr>
-##  1                 Item
-##  2      LUExtractSource
-##  3     LUMarkerEvidence
-##  4         LUMarkerType
-##  5      LUMultipleBirth
-##  6         LURaceCohort
-##  7   LURelationshipPath
-##  8         LURosterGen1
-##  9       LUSurveySource
-## 10           LUTristate
-## 11              LUYesNo
-## 12             MzManual
-## 13 RosterGen1Assignment
-## 14             Variable
-## # ... with 3 more variables: path <chr>, col_types <list>, exists <lgl>
+##    name                 path                              col_types  exis~
+##    <chr>                <chr>                             <list>     <lgl>
+##  1 item                 data-public/metadata/tables-79/i~ <S3: col_~ T    
+##  2 LUExtractSource      data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  3 LUMarkerEvidence     data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  4 LUMarkerType         data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  5 LUMultipleBirth      data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  6 LURaceCohort         data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  7 LURelationshipPath   data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  8 LURosterGen1         data-public/metadata/tables-79/L~ <S3: col_~ T    
+##  9 LUSurveySource       data-public/metadata/tables-79/L~ <S3: col_~ T    
+## 10 LUTristate           data-public/metadata/tables-79/L~ <S3: col_~ T    
+## 11 LUYesNo              data-public/metadata/tables-79/L~ <S3: col_~ T    
+## 12 MzManual             data-public/metadata/tables-79/M~ <S3: col_~ T    
+## 13 RosterGen1Assignment data-public/metadata/tables-79/R~ <S3: col_~ T    
+## 14 variable             data-public/metadata/tables-79/v~ <S3: col_~ T
 
testit::assert("All metadata files must exist.", all(ds_file$exists))
 
 ds_entries <- ds_file %>%
+  # dplyr::slice(15) %>%
   dplyr::select(name, path, col_types) %>%
   dplyr::mutate(
-    entries = purrr::pmap(list(file=.$path, col_types=.$col_types), readr::read_csv)
+    entries = purrr::pmap(list(file=.$path, col_types=.$col_types), readr::read_csv, comment = "#")
   )
 ds_entries
 
## # A tibble: 14 x 4
-##                    name
-##                   <chr>
-##  1                 Item
-##  2      LUExtractSource
-##  3     LUMarkerEvidence
-##  4         LUMarkerType
-##  5      LUMultipleBirth
-##  6         LURaceCohort
-##  7   LURelationshipPath
-##  8         LURosterGen1
-##  9       LUSurveySource
-## 10           LUTristate
-## 11              LUYesNo
-## 12             MzManual
-## 13 RosterGen1Assignment
-## 14             Variable
-## # ... with 3 more variables: path <chr>, col_types <list>, entries <list>
+##    name                 path                        col_types entries     
+##    <chr>                <chr>                       <list>    <list>      
+##  1 item                 data-public/metadata/table~ <S3: col~ <tibble [11~
+##  2 LUExtractSource      data-public/metadata/table~ <S3: col~ <tibble [12~
+##  3 LUMarkerEvidence     data-public/metadata/table~ <S3: col~ <tibble [8 ~
+##  4 LUMarkerType         data-public/metadata/table~ <S3: col~ <tibble [28~
+##  5 LUMultipleBirth      data-public/metadata/table~ <S3: col~ <tibble [5 ~
+##  6 LURaceCohort         data-public/metadata/table~ <S3: col~ <tibble [3 ~
+##  7 LURelationshipPath   data-public/metadata/table~ <S3: col~ <tibble [5 ~
+##  8 LURosterGen1         data-public/metadata/table~ <S3: col~ <tibble [67~
+##  9 LUSurveySource       data-public/metadata/table~ <S3: col~ <tibble [5 ~
+## 10 LUTristate           data-public/metadata/table~ <S3: col~ <tibble [3 ~
+## 11 LUYesNo              data-public/metadata/table~ <S3: col~ <tibble [6 ~
+## 12 MzManual             data-public/metadata/table~ <S3: col~ <tibble [20~
+## 13 RosterGen1Assignment data-public/metadata/table~ <S3: col~ <tibble [50~
+## 14 variable             data-public/metadata/table~ <S3: col~ <tibble [1,~
 
-
# d <- readr::read_csv("data-public/metadata/tables/LURosterGen1.csv", col_types=lst_col_types$LURosterGen1)
+
# d <- readr::read_csv("data-public/metadata/tables/variable_79.csv", col_types=lst_col_types$variable_79, comment = "#")
+# readr::problems(d)
+# ds_entries$entries[15]
 
 ds_table <- database_inventory()
 ds_table
@@ -441,28 +466,28 @@
 ## 1      Archive      tblArchiveDescription        55            4
 ## 2      Archive    tblRelatedValuesArchive    676582           24
 ## 3          dbo                sysdiagrams         4            5
-## 4          dbo                 tblIRDemo2         0            3
-## 5         Enum    tblLUBioparent-not-used         0            2
-## 6         Enum         tblLUExtractSource        11            4
-## 7         Enum                tblLUGender         3            4
-## 8         Enum        tblLUMarkerEvidence         8            4
-## 9         Enum            tblLUMarkerType        28            5
-## 10        Enum         tblLUMultipleBirth         5            4
-## 11        Enum            tblLURaceCohort         3            4
-## 12        Enum      tblLURelationshipPath         5            4
-## 13        Enum            tblLURosterGen1        67            4
-## 14        Enum          tblLUSurveySource         4            4
-## 15        Enum              tblLUTristate         3            4
-## 16        Enum                 tblLUYesNo         6            4
+## 4         Enum    tblLUBioparent-not-used         0            2
+## 5         Enum         tblLUExtractSource        12            4
+## 6         Enum                tblLUGender         3            4
+## 7         Enum        tblLUMarkerEvidence         8            4
+## 8         Enum            tblLUMarkerType        28            5
+## 9         Enum         tblLUMultipleBirth         5            4
+## 10        Enum            tblLURaceCohort         3            4
+## 11        Enum      tblLURelationshipPath         5            4
+## 12        Enum            tblLURosterGen1        67            4
+## 13        Enum          tblLUSurveySource         5            4
+## 14        Enum              tblLUTristate         3            4
+## 15        Enum                 tblLUYesNo         6            4
+## 16     Extract                tbl97Roster         0          416
 ## 17     Extract            tblGen1Explicit     12686           96
 ## 18     Extract    tblGen1GeocodeSanitized      5302           29
 ## 19     Extract            tblGen1Implicit     12686          102
-## 20     Extract               tblGen1Links     12686           96
+## 20     Extract               tblGen1Links     12686          117
 ## 21     Extract tblGen1MzDzDistinction2010         0            7
 ## 22     Extract            tblGen1Outcomes     12686           22
-## 23     Extract      tblGen2FatherFromGen1     12686          939
+## 23     Extract      tblGen2FatherFromGen1     12686          959
 ## 24     Extract      tblGen2ImplicitFather     11521          111
-## 25     Extract               tblGen2Links     11521          164
+## 25     Extract               tblGen2Links     11521          207
 ## 26     Extract       tblGen2LinksFromGen1     12686          123
 ## 27     Extract      tblGen2OutcomesHeight     11521           46
 ## 28     Extract        tblGen2OutcomesMath     11521           44
@@ -470,24 +495,26 @@
 ## 30     Extract           tblLinks2004Gen1      3890            9
 ## 31     Extract           tblLinks2004Gen2     12855            5
 ## 32    Metadata                    tblItem       110            7
-## 33    Metadata                tblMzManual       208            9
-## 34    Metadata    tblRosterGen1Assignment        50           16
-## 35    Metadata                tblVariable      1575           11
-## 36     Process               tblBabyDaddy         0           11
-## 37     Process            tblFatherOfGen2         0            7
-## 38     Process                 tblIRDemo1         0            5
-## 39     Process              tblMarkerGen1         0           10
-## 40     Process              tblMarkerGen2         0            8
-## 41     Process                 tblOutcome         0            5
-## 42     Process    tblParentsOfGen1Current         0           19
-## 43     Process      tblParentsOfGen1Retro         0            7
-## 44     Process        tblRelatedStructure         0            6
-## 45     Process           tblRelatedValues         0           24
-## 46     Process                tblResponse         0            9
-## 47     Process              tblRosterGen1         0           13
-## 48     Process                 tblSubject         0            5
-## 49     Process          tblSubjectDetails         0           15
-## 50     Process              tblSurveyTime         0            7
+## 33    Metadata                 tblItem_97         7            7
+## 34    Metadata                tblMzManual       208            9
+## 35    Metadata    tblRosterGen1Assignment        50           16
+## 36    Metadata                tblVariable      1642           10
+## 37    Metadata             tblVariable_97        37           10
+## 38     Process               tblBabyDaddy         0           11
+## 39     Process            tblFatherOfGen2         0            7
+## 40     Process                 tblIRDemo1         0            5
+## 41     Process              tblMarkerGen1         0           10
+## 42     Process              tblMarkerGen2         0            8
+## 43     Process                 tblOutcome         0            5
+## 44     Process    tblParentsOfGen1Current         0           19
+## 45     Process      tblParentsOfGen1Retro         0            7
+## 46     Process        tblRelatedStructure         0            6
+## 47     Process           tblRelatedValues         0           24
+## 48     Process                tblResponse         0            9
+## 49     Process              tblRosterGen1         0           13
+## 50     Process                 tblSubject         0            5
+## 51     Process          tblSubjectDetails         0           15
+## 52     Process              tblSurveyTime         0            7
 
rm(directory_in) # rm(col_types_tulsa)
@@ -498,8 +525,10 @@
 ds_file <- ds_file %>%
   dplyr::left_join( ds_mapping, by=c("name"="table_name")) %>%
   dplyr::mutate(
-    table_name    = paste0(schema_name, ".tbl", name),
-    sql_delete    = paste0("DELETE FROM ", table_name)
+    table_name    = paste0("tbl", name),
+    sql_delete    = glue::glue("DELETE FROM {schema_name}.{table_name};")
+    # table_name    = paste0(schema_name, ".tbl", name),
+    # sql_delete    = paste0("DELETE FROM ", table_name)
   ) %>%
   dplyr::left_join(
     ds_entries %>%
@@ -513,165 +542,162 @@
 
## # A tibble: 110 x 7
-##       ID                              Label MinValue MinNonnegative
-##    <int>                              <chr>    <int>          <int>
-##  1     1            IDOfOther1979RosterGen1       -4              1
-##  2     2                      RosterGen1979       -4              1
-##  3     3 SiblingNumberFrom1993SiblingRoster       -4              1
-##  4     4           IDCodeOfOtherSiblingGen1       -5              3
-##  5     5                    ShareBiomomGen1       -5              0
-##  6     6                    ShareBiodadGen1       -5              0
-##  7     9 IDCodeOfOtherInterviewedBiodadGen2       -7              1
-##  8    10                    ShareBiodadGen2       -7              0
-##  9    11               Gen1MomOfGen2Subject        2              2
-## 10    13                   DateOfBirthMonth       -5              1
-## # ... with 100 more rows, and 3 more variables: MaxValue <int>,
-## #   Active <lgl>, Notes <chr>
-## # A tibble: 11 x 4
-##       ID              Label Active Notes
-##    <int>              <chr>  <lgl> <chr>
-##  1     3          Gen1Links   TRUE  <NA>
-##  2     4          Gen2Links   TRUE  <NA>
-##  3     5  Gen2LinksFromGen1   TRUE  <NA>
-##  4     6 Gen2ImplicitFather   TRUE  <NA>
-##  5     7 Gen2FatherFromGen1   TRUE  <NA>
-##  6     8       Gen1Outcomes   TRUE  <NA>
-##  7     9 Gen2OutcomesHeight   TRUE  <NA>
-##  8    10       Gen1Explicit   TRUE  <NA>
-##  9    11       Gen1Implicit   TRUE  <NA>
-## 10    12 Gen2OutcomesWeight   TRUE  <NA>
-## 11    13   Gen2OutcomesMath   TRUE  <NA>
+##       ID Label                              MinVa~ MinN~ MaxV~ Acti~ Notes
+##    <int> <chr>                               <int> <int> <int> <lgl> <chr>
+##  1     1 IDOfOther1979RosterGen1                -4     1 12557 T     <NA> 
+##  2     2 RosterGen1979                          -4     1    66 T     <NA> 
+##  3     3 SiblingNumberFrom1993SiblingRoster     -4     1    99 T     <NA> 
+##  4     4 IDCodeOfOtherSiblingGen1               -5     3 12518 T     <NA> 
+##  5     5 ShareBiomomGen1                        -5     0     2 T     <NA> 
+##  6     6 ShareBiodadGen1                        -5     0     2 T     <NA> 
+##  7     9 IDCodeOfOtherInterviewedBiodadGen2     -7     1    11 T     <NA> 
+##  8    10 ShareBiodadGen2                        -7     0     3 T     <NA> 
+##  9    11 Gen1MomOfGen2Subject                    2     2 12675 T     <NA> 
+## 10    13 DateOfBirthMonth                       -5     1    12 T     <NA> 
+## # ... with 100 more rows
+## # A tibble: 12 x 4
+##       ID Label              Active Notes
+##    <int> <chr>              <lgl>  <chr>
+##  1     3 Gen1Links          T      <NA> 
+##  2     4 Gen2Links          T      <NA> 
+##  3     5 Gen2LinksFromGen1  T      <NA> 
+##  4     6 Gen2ImplicitFather T      <NA> 
+##  5     7 Gen2FatherFromGen1 T      <NA> 
+##  6     8 Gen1Outcomes       T      <NA> 
+##  7     9 Gen2OutcomesHeight T      <NA> 
+##  8    10 Gen1Explicit       T      <NA> 
+##  9    11 Gen1Implicit       T      <NA> 
+## 10    12 Gen2OutcomesWeight T      <NA> 
+## 11    13 Gen2OutcomesMath   T      <NA> 
+## 12   100 gen_1_97_roster    T      <NA> 
 ## # A tibble: 8 x 4
-##      ID            Label Active Notes
-##   <int>            <chr>  <lgl> <chr>
-## 1     0       Irrelevant   TRUE  <NA>
-## 2     1 StronglySupports   TRUE  <NA>
-## 3     2         Supports   TRUE  <NA>
-## 4     3       Consistent   TRUE  <NA>
-## 5     4        Ambiguous   TRUE  <NA>
-## 6     5          Missing   TRUE  <NA>
-## 7     6         Unlikely   TRUE  <NA>
-## 8     7      Disconfirms   TRUE  <NA>
+##      ID Label            Active Notes
+##   <int> <chr>            <lgl>  <chr>
+## 1     0 Irrelevant       T      <NA> 
+## 2     1 StronglySupports T      <NA> 
+## 3     2 Supports         T      <NA> 
+## 4     3 Consistent       T      <NA> 
+## 5     4 Ambiguous        T      <NA> 
+## 6     5 Missing          T      <NA> 
+## 7     6 Unlikely         T      <NA> 
+## 8     7 Disconfirms      T      <NA> 
 ## # A tibble: 28 x 5
-##       ID               Label Explicit Active Notes
-##    <int>               <chr>    <int>  <lgl> <chr>
-##  1     1          RosterGen1        1   TRUE  <NA>
-##  2     2         ShareBiomom        1   TRUE  <NA>
-##  3     3         ShareBiodad        1   TRUE  <NA>
-##  4     5       DobSeparation        0   TRUE  <NA>
-##  5     6     GenderAgreement        0   TRUE  <NA>
-##  6    10        FatherAsthma        0   TRUE  <NA>
-##  7    11     BabyDaddyAsthma        0   TRUE  <NA>
-##  8    12 BabyDaddyLeftHHDate        0   TRUE  <NA>
-##  9    13  BabyDaddyDeathDate        0   TRUE  <NA>
-## 10    14      BabyDaddyAlive        0   TRUE  <NA>
+##       ID Label               Explicit Active Notes
+##    <int> <chr>                  <int> <lgl>  <chr>
+##  1     1 RosterGen1                 1 T      <NA> 
+##  2     2 ShareBiomom                1 T      <NA> 
+##  3     3 ShareBiodad                1 T      <NA> 
+##  4     5 DobSeparation              0 T      <NA> 
+##  5     6 GenderAgreement            0 T      <NA> 
+##  6    10 FatherAsthma               0 T      <NA> 
+##  7    11 BabyDaddyAsthma            0 T      <NA> 
+##  8    12 BabyDaddyLeftHHDate        0 T      <NA> 
+##  9    13 BabyDaddyDeathDate         0 T      <NA> 
+## 10    14 BabyDaddyAlive             0 T      <NA> 
 ## # ... with 18 more rows
 ## # A tibble: 5 x 4
-##      ID      Label Active
-##   <int>      <chr>  <lgl>
-## 1     0         No   TRUE
-## 2     2       Twin   TRUE
-## 3     3       Trip   TRUE
-## 4     4 TwinOrTrip   TRUE
-## 5   255  DoNotKnow   TRUE
-## # ... with 1 more variables: Notes <chr>
+##      ID Label      Active Notes                                           
+##   <int> <chr>      <lgl>  <chr>                                           
+## 1     0 No         T      <NA>                                            
+## 2     2 Twin       T      <NA>                                            
+## 3     3 Trip       T      <NA>                                            
+## 4     4 TwinOrTrip T      Currently Then Gen1 algorithm doesn't distingui~
+## 5   255 DoNotKnow  T      <NA>                                            
 ## # A tibble: 3 x 4
-##      ID    Label Active Notes
-##   <int>    <chr>  <lgl> <chr>
-## 1     1 Hispanic   TRUE  <NA>
-## 2     2    Black   TRUE  <NA>
-## 3     3     Nbnh   TRUE  <NA>
+##      ID Label    Active Notes
+##   <int> <chr>    <lgl>  <chr>
+## 1     1 Hispanic T      <NA> 
+## 2     2 Black    T      <NA> 
+## 3     3 Nbnh     T      <NA> 
 ## # A tibble: 5 x 4
-##      ID          Label Active                                Notes
-##   <int>          <chr>  <lgl>                                <chr>
-## 1     1 Gen1Housemates   TRUE                                 <NA>
-## 2     2   Gen2Siblings   TRUE                                 <NA>
-## 3     3    Gen2Cousins   TRUE                                 <NA>
-## 4     4    ParentChild   TRUE                                 <NA>
-## 5     5      AuntNiece   TRUE Acutally (Uncle|Aunt)-(Nephew|Niece)
+##      ID Label          Active Notes                               
+##   <int> <chr>          <lgl>  <chr>                               
+## 1     1 Gen1Housemates T      <NA>                                
+## 2     2 Gen2Siblings   T      <NA>                                
+## 3     3 Gen2Cousins    T      <NA>                                
+## 4     4 ParentChild    T      <NA>                                
+## 5     5 AuntNiece      T      Actually (Uncle|Aunt)-(Nephew|Niece)
 ## # A tibble: 67 x 4
-##       ID       Label Active Notes
-##    <int>       <chr>  <lgl> <chr>
-##  1    -4   ValidSkip   TRUE  <NA>
-##  2    -3 InvalidSkip   TRUE  <NA>
-##  3    -1     Refusal   TRUE  <NA>
-##  4     0  Respondent   TRUE  <NA>
-##  5     1      Spouse   TRUE  <NA>
-##  6     2         Son   TRUE  <NA>
-##  7     3    Daughter   TRUE  <NA>
-##  8     4      Father   TRUE  <NA>
-##  9     5      Mother   TRUE  <NA>
-## 10     6     Brother   TRUE  <NA>
+##       ID Label       Active Notes
+##    <int> <chr>       <lgl>  <chr>
+##  1    -4 ValidSkip   T      <NA> 
+##  2    -3 InvalidSkip T      <NA> 
+##  3    -1 Refusal     T      <NA> 
+##  4     0 Respondent  T      <NA> 
+##  5     1 Spouse      T      <NA> 
+##  6     2 Son         T      <NA> 
+##  7     3 Daughter    T      <NA> 
+##  8     4 Father      T      <NA> 
+##  9     5 Mother      T      <NA> 
+## 10     6 Brother     T      <NA> 
 ## # ... with 57 more rows
-## # A tibble: 4 x 4
-##      ID       Label Active Notes
-##   <int>       <chr>  <lgl> <chr>
-## 1     0 NoInterview   TRUE  <NA>
-## 2     1        Gen1   TRUE  <NA>
-## 3     2       Gen2C   TRUE  <NA>
-## 4     3      Gen2YA   TRUE  <NA>
+## # A tibble: 5 x 4
+##      ID Label       Active Notes
+##   <int> <chr>       <lgl>  <chr>
+## 1     0 NoInterview T      <NA> 
+## 2     1 Gen1        T      <NA> 
+## 3     2 Gen2C       T      <NA> 
+## 4     3 Gen2YA      T      <NA> 
+## 5     4 97          T      <NA> 
 ## # A tibble: 3 x 4
-##      ID     Label Active Notes
-##   <int>     <chr>  <lgl> <chr>
-## 1     0        No   TRUE  <NA>
-## 2     1       Yes   TRUE  <NA>
-## 3   255 DoNotKnow   TRUE  <NA>
+##      ID Label     Active Notes
+##   <int> <chr>     <lgl>  <chr>
+## 1     0 No        T      <NA> 
+## 2     1 Yes       T      <NA> 
+## 3   255 DoNotKnow T      <NA> 
 ## # A tibble: 6 x 4
-##      ID                               Label Active Notes
-##   <int>                               <chr>  <lgl> <chr>
-## 1    -6 ValidSkipOrNoInterviewOrNotInSurvey   TRUE  <NA>
-## 2    -3                         InvalidSkip   TRUE  <NA>
-## 3    -2                           DoNotKnow   TRUE  <NA>
-## 4    -1                             Refusal   TRUE  <NA>
-## 5     0                                  No   TRUE  <NA>
-## 6     1                                 Yes   TRUE  <NA>
+##      ID Label                               Active Notes
+##   <int> <chr>                               <lgl>  <chr>
+## 1    -6 ValidSkipOrNoInterviewOrNotInSurvey T      <NA> 
+## 2    -3 InvalidSkip                         T      <NA> 
+## 3    -2 DoNotKnow                           T      <NA> 
+## 4    -1 Refusal                             T      <NA> 
+## 5     0 No                                  T      <NA> 
+## 6     1 Yes                                 T      <NA> 
 ## # A tibble: 208 x 9
-##       ID SubjectTag_S1 SubjectTag_S2 Generation MultipleBirthIfSameSex
-##    <int>         <int>         <int>      <int>                  <int>
-##  1     1          5003          5004          2                      2
-##  2     3         14303         14304          2                      2
-##  3     5         15904         15905          2                      2
-##  4     6         28805         28806          2                      2
-##  5     8         36504         36505          2                      2
-##  6     9         67703         67704          2                      2
-##  7    10         73301         73302          2                      2
-##  8    12         74301         74302          2                      2
-##  9    13         77502         77503          2                      2
-## 10    14         93001         93002          2                      2
-## # ... with 198 more rows, and 4 more variables: IsMz <int>,
-## #   Undecided <int>, Related <int>, Notes <chr>
+##       ID SubjectTag_S1 SubjectTag_S2 Gener~ Multi~  IsMz Unde~ Rela~ Notes
+##    <int>         <int>         <int>  <int>  <int> <int> <int> <int> <chr>
+##  1     1          5003          5004      2      2     0     0     1 Very~
+##  2     3         14303         14304      2      2     0     0     1 Diff~
+##  3     5         15904         15905      2      2     0     0     1 <NA> 
+##  4     6         28805         28806      2      2     0     0     1 Diff~
+##  5     8         36504         36505      2      2     1     0     1 Twic~
+##  6     9         67703         67704      2      2     0     0     1 1994~
+##  7    10         73301         73302      2      2     1     0     1 Most~
+##  8    12         74301         74302      2      2     0     0     1 Diff~
+##  9    13         77502         77503      2      2     1     0     1 1994~
+## 10    14         93001         93002      2      2     1     0     1 1994~
+## # ... with 198 more rows
 ## # A tibble: 50 x 16
-##       ID ResponseLower ResponseUpper  Freq Resolved     R RBoundLower
-##    <int>         <int>         <int> <int>    <int> <dbl>       <dbl>
-##  1     1            -3            -3    67        0    NA       0.000
-##  2     2            -3            -1    11        0    NA       0.000
-##  3     3            -3            33     6        1 0.000       0.000
-##  4     4            -3            36    35        1 0.000       0.000
-##  5     5            -1            18     1        1 0.125       0.125
-##  6     6            -1            36     3        1 0.000       0.000
-##  7     7             1             1   167        1 0.000       0.000
-##  8     8             1            33     1        1 0.000       0.000
-##  9     9             1            36     1        1 0.000       0.000
-## 10    10             1            57     1        1 0.000       0.000
-## # ... with 40 more rows, and 9 more variables: RBoundUpper <dbl>,
-## #   SameGeneration <int>, ShareBiodad <int>, ShareBiomom <int>,
-## #   ShareBiograndparent <int>, Inconsistent <int>, Notes <chr>,
-## #   ResponseLowerLabel <chr>, ResponseUpperLabel <chr>
-## # A tibble: 1,575 x 11
-##       ID VariableCode  Item Generation ExtractSource SurveySource
-##    <int>        <chr> <int>      <int>         <int>        <int>
-##  1     1     R0000149   101          1             3            1
-##  2     2     R0216500    16          1             3            1
-##  3     3     R0406510    16          1             3            1
-##  4     4     R0619010    16          1             3            1
-##  5     5     R0898310    16          1             3            1
-##  6     6     R1145110    16          1             3            1
-##  7     7     R1520310    16          1             3            1
-##  8     8     R1891010    16          1             3            1
-##  9     9     R2258110    16          1             3            1
-## 10    10     R2445510    16          1             3            1
-## # ... with 1,565 more rows, and 5 more variables: SurveyYear <int>,
-## #   LoopIndex <int>, Translate <int>, Active <lgl>, Notes <chr>
+##       ID Respo~ Respo~  Freq Resol~      R RBoun~ RBoun~ Same~ Shar~ Shar~
+##    <int>  <int>  <int> <int>  <int>  <dbl>  <dbl>  <dbl> <int> <int> <int>
+##  1     1     -3    - 3    67      0 NA      0      1.00    255   255   255
+##  2     2     -3    - 1    11      0 NA      0      1.00    255   255   255
+##  3     3     -3     33     6      1  0      0      0         1     0     0
+##  4     4     -3     36    35      1  0      0      0       255     0     0
+##  5     5     -1     18     1      1  0.125  0.125  0.125     0     0     0
+##  6     6     -1     36     3      1  0      0      0       255     0     0
+##  7     7      1      1   167      1  0      0      0         1     0     0
+##  8     8      1     33     1      1  0      0      0         1     0     0
+##  9     9      1     36     1      1  0      0      0         1     0     0
+## 10    10      1     57     1      1  0      0      0         1     0     0
+## # ... with 40 more rows, and 5 more variables: ShareBiograndparent <int>,
+## #   Inconsistent <int>, Notes <chr>, ResponseLowerLabel <chr>,
+## #   ResponseUpperLabel <chr>
+## # A tibble: 1,642 x 10
+##    VariableCode  Item Generation Extr~ Surv~ Surv~ Loop~ Tran~ Acti~ Notes
+##    <chr>        <int>      <int> <int> <int> <int> <int> <int> <int> <chr>
+##  1 R0000100       100          1     3     1  1979     0     0     1 Is r~
+##  2 C0000100       100          2     6     2     0     0     0     1 Is r~
+##  3 R0000149       101          1     3     1  1979     0     0     1 Is r~
+##  4 R0214800       102          1     3     1  1979     0     0     1 Is r~
+##  5 C0005400       102          2     4     2     0     0     0     1 Is r~
+##  6 R0214700       103          1     3     1  1979     0     1     1 No m~
+##  7 C0005300       103          2     4     2     0     0     1     1 no m~
+##  8 R0000150         1          1    10     1  1979     1     1     1 <NA> 
+##  9 R0000152         1          1    10     1  1979     2     1     1 <NA> 
+## 10 R0000154         1          1    10     1  1979     3     1     1 <NA> 
+## # ... with 1,632 more rows
 
# ds_file %>%
@@ -696,39 +722,35 @@
 ds_file$table_name
 
-
##  [1] "Metadata.tblItem"                 "Enum.tblLUExtractSource"         
-##  [3] "Enum.tblLUMarkerEvidence"         "Enum.tblLUMarkerType"            
-##  [5] "Enum.tblLUMultipleBirth"          "Enum.tblLURaceCohort"            
-##  [7] "Enum.tblLURelationshipPath"       "Enum.tblLURosterGen1"            
-##  [9] "Enum.tblLUSurveySource"           "Enum.tblLUTristate"              
-## [11] "Enum.tblLUYesNo"                  "Metadata.tblMzManual"            
-## [13] "Metadata.tblRosterGen1Assignment" "Metadata.tblVariable"
+
##  [1] "tblitem"                 "tblLUExtractSource"     
+##  [3] "tblLUMarkerEvidence"     "tblLUMarkerType"        
+##  [5] "tblLUMultipleBirth"      "tblLURaceCohort"        
+##  [7] "tblLURelationshipPath"   "tblLURosterGen1"        
+##  [9] "tblLUSurveySource"       "tblLUTristate"          
+## [11] "tblLUYesNo"              "tblMzManual"            
+## [13] "tblRosterGen1Assignment" "tblvariable"
 
ds_file
 
## # A tibble: 14 x 11
-##                    name
-##                   <chr>
-##  1                 Item
-##  2      LUExtractSource
-##  3     LUMarkerEvidence
-##  4         LUMarkerType
-##  5      LUMultipleBirth
-##  6         LURaceCohort
-##  7   LURelationshipPath
-##  8         LURosterGen1
-##  9       LUSurveySource
-## 10           LUTristate
-## 11              LUYesNo
-## 12             MzManual
-## 13 RosterGen1Assignment
-## 14             Variable
-## # ... with 10 more variables: path <chr>, col_types <list>, exists <lgl>,
-## #   schema_name <chr>, enum_name <chr>, c_sharp_type <chr>,
-## #   convert_to_enum <lgl>, table_name <chr>, sql_delete <chr>,
-## #   entries <list>
+##    name   path    col_t~ exists sche~ enum~ c_sh~ conv~ tabl~ sql_d~ entr~
+##    <chr>  <chr>   <list> <lgl>  <chr> <chr> <chr> <lgl> <chr> <chr>  <lis>
+##  1 item   data-p~ <S3: ~ T      Meta~ item  short T     tbli~ DELET~ <tib~
+##  2 LUExt~ data-p~ <S3: ~ T      Enum  Extr~ byte  T     tblL~ DELET~ <tib~
+##  3 LUMar~ data-p~ <S3: ~ T      Enum  Mark~ byte  T     tblL~ DELET~ <tib~
+##  4 LUMar~ data-p~ <S3: ~ T      Enum  Mark~ byte  T     tblL~ DELET~ <tib~
+##  5 LUMul~ data-p~ <S3: ~ T      Enum  Mult~ byte  T     tblL~ DELET~ <tib~
+##  6 LURac~ data-p~ <S3: ~ T      Enum  Race~ byte  T     tblL~ DELET~ <tib~
+##  7 LURel~ data-p~ <S3: ~ T      Enum  Rela~ byte  T     tblL~ DELET~ <tib~
+##  8 LURos~ data-p~ <S3: ~ T      Enum  Rost~ short T     tblL~ DELET~ <tib~
+##  9 LUSur~ data-p~ <S3: ~ T      Enum  Surv~ byte  T     tblL~ DELET~ <tib~
+## 10 LUTri~ data-p~ <S3: ~ T      Enum  Tris~ byte  T     tblL~ DELET~ <tib~
+## 11 LUYes~ data-p~ <S3: ~ T      Enum  YesNo short T     tblL~ DELET~ <tib~
+## 12 MzMan~ data-p~ <S3: ~ T      Meta~ NA_c~ NA_c~ F     tblM~ DELET~ <tib~
+## 13 Roste~ data-p~ <S3: ~ T      Meta~ NA_c~ NA_c~ F     tblR~ DELET~ <tib~
+## 14 varia~ data-p~ <S3: ~ T      Meta~ NA_c~ NA_c~ F     tblv~ DELET~ <tib~
 
create_enum_body <- function( d ) {
@@ -760,7 +782,7 @@
 
## 
-## public enum Item {
+## public enum item {
 ##     IDOfOther1979RosterGen1                                      =     1, 
 ##     RosterGen1979                                                =     2, 
 ##     SiblingNumberFrom1993SiblingRoster                           =     3, 
@@ -885,6 +907,7 @@
 ##     Gen1Implicit                                                 =    11, 
 ##     Gen2OutcomesWeight                                           =    12, 
 ##     Gen2OutcomesMath                                             =    13, 
+##     gen_1_97_roster                                              =   100, 
 ## }
 ##  
 ## public enum MarkerEvidence {
@@ -948,7 +971,7 @@
 ##     Gen2Siblings                                                 =     2, 
 ##     Gen2Cousins                                                  =     3, 
 ##     ParentChild                                                  =     4, 
-##     AuntNiece                                                    =     5, // Acutally (Uncle|Aunt)-(Nephew|Niece)
+##     AuntNiece                                                    =     5, // Actually (Uncle|Aunt)-(Nephew|Niece)
 ## }
 ##  
 ## public enum RosterGen1 {
@@ -1026,6 +1049,7 @@
 ##     Gen1                                                         =     1, 
 ##     Gen2C                                                        =     2, 
 ##     Gen2YA                                                       =     3, 
+##     97                                                           =     4, 
 ## }
 ##  
 ## public enum Tristate {
@@ -1064,67 +1088,176 @@
 ds_table_process <- ds_table %>%
   dplyr::filter(schema_name == "Process") %>%
   dplyr::mutate(
-    #sql_truncate  = glue::glue("TRUNCATE TABLE {schema_name}.{table_name};")
+    # sql_truncate  = glue::glue("TRUNCATE TABLE {schema_name}.{table_name};")
     sql_truncate  = glue::glue("DELETE FROM {schema_name}.{table_name};")
   )
 
 # Open channel
-channel <- open_dsn_channel()
-RODBC::odbcGetInfo(channel)
+channel <- open_dsn_channel_odbc()
+DBI::dbGetInfo(channel)
+
+ +
## $dbname
+## [1] "NlsyLinks79"
+## 
+## $dbms.name
+## [1] "Microsoft SQL Server"
+## 
+## $db.version
+## [1] "13.00.4206"
+## 
+## $username
+## [1] "dbo"
+## 
+## $host
+## [1] ""
+## 
+## $port
+## [1] ""
+## 
+## $sourcename
+## [1] "local-nlsy-links-79"
+## 
+## $servername
+## [1] "GIMBLE\\EXPRESS_2016"
+## 
+## $drivername
+## [1] "msodbcsql13.dll"
+## 
+## $odbc.version
+## [1] "03.80.0000"
+## 
+## $driver.version
+## [1] "14.00.0500"
+## 
+## $odbcdriver.version
+## [1] "03.80"
+## 
+## $supports.transactions
+## [1] TRUE
+## 
+## attr(,"class")
+## [1] "Microsoft SQL Server" "driver_info"          "list"
+
+ +
channel_rodbc <- open_dsn_channel_rodbc()
+RODBC::odbcGetInfo(channel_rodbc)
 
##              DBMS_Name               DBMS_Ver        Driver_ODBC_Ver 
 ## "Microsoft SQL Server"           "13.00.4206"                "03.80" 
 ##       Data_Source_Name            Driver_Name             Driver_Ver 
-##     "local-nlsy-links"      "msodbcsql13.dll"           "14.00.0500" 
+##  "local-nlsy-links-79"      "msodbcsql13.dll"           "14.00.0500" 
 ##               ODBC_Ver            Server_Name 
 ##           "03.80.0000" "GIMBLE\\EXPRESS_2016"
 
# Clear process tables
 delete_results_process <- ds_table_process$sql_truncate %>%
-  rev() %>%
   purrr::set_names(ds_table_process$table_name) %>%
-  purrr::map_int(RODBC::sqlQuery, channel=channel, errors=FALSE)
+  rev() %>%
+  purrr::map(DBI::dbGetQuery, conn=channel)
 delete_results_process
 
-
##            tblBabyDaddy         tblFatherOfGen2              tblIRDemo1 
-##                      -1                      -1                      -1 
-##           tblMarkerGen1           tblMarkerGen2              tblOutcome 
-##                      -1                      -1                      -1 
-## tblParentsOfGen1Current   tblParentsOfGen1Retro     tblRelatedStructure 
-##                      -1                      -1                      -1 
-##        tblRelatedValues             tblResponse           tblRosterGen1 
-##                      -1                      -1                      -1 
-##              tblSubject       tblSubjectDetails           tblSurveyTime 
-##                      -1                      -1                      -1
+
## $tblSurveyTime
+## data frame with 0 columns and 0 rows
+## 
+## $tblSubjectDetails
+## data frame with 0 columns and 0 rows
+## 
+## $tblSubject
+## data frame with 0 columns and 0 rows
+## 
+## $tblRosterGen1
+## data frame with 0 columns and 0 rows
+## 
+## $tblResponse
+## data frame with 0 columns and 0 rows
+## 
+## $tblRelatedValues
+## data frame with 0 columns and 0 rows
+## 
+## $tblRelatedStructure
+## data frame with 0 columns and 0 rows
+## 
+## $tblParentsOfGen1Retro
+## data frame with 0 columns and 0 rows
+## 
+## $tblParentsOfGen1Current
+## data frame with 0 columns and 0 rows
+## 
+## $tblOutcome
+## data frame with 0 columns and 0 rows
+## 
+## $tblMarkerGen2
+## data frame with 0 columns and 0 rows
+## 
+## $tblMarkerGen1
+## data frame with 0 columns and 0 rows
+## 
+## $tblIRDemo1
+## data frame with 0 columns and 0 rows
+## 
+## $tblFatherOfGen2
+## data frame with 0 columns and 0 rows
+## 
+## $tblBabyDaddy
+## data frame with 0 columns and 0 rows
 
# Delete metadata tables
 # delete_result <- RODBC::sqlQuery(channel, "DELETE FROM [NlsLinks].[Metadata].[tblVariable]", errors=FALSE)
 delete_results_metadata <- ds_file$sql_delete %>%
-  rev() %>%
   purrr::set_names(ds_file$table_name) %>%
-  purrr::map_int(RODBC::sqlQuery, channel=channel, errors=FALSE)
+  rev() %>%
+  purrr::map(DBI::dbGetQuery, conn=channel)
 
+# DBI::dbGetQuery(conn=channel, ds_file$sql_delete[15])
 delete_results_metadata
 
-
##                 Metadata.tblItem          Enum.tblLUExtractSource 
-##                               -2                               -2 
-##         Enum.tblLUMarkerEvidence             Enum.tblLUMarkerType 
-##                               -2                               -2 
-##          Enum.tblLUMultipleBirth             Enum.tblLURaceCohort 
-##                               -2                               -2 
-##       Enum.tblLURelationshipPath             Enum.tblLURosterGen1 
-##                               -2                               -2 
-##           Enum.tblLUSurveySource               Enum.tblLUTristate 
-##                               -2                               -2 
-##                  Enum.tblLUYesNo             Metadata.tblMzManual 
-##                               -2                               -2 
-## Metadata.tblRosterGen1Assignment             Metadata.tblVariable 
-##                               -2                               -2
+
## $tblvariable
+## data frame with 0 columns and 0 rows
+## 
+## $tblRosterGen1Assignment
+## data frame with 0 columns and 0 rows
+## 
+## $tblMzManual
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUYesNo
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUTristate
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUSurveySource
+## data frame with 0 columns and 0 rows
+## 
+## $tblLURosterGen1
+## data frame with 0 columns and 0 rows
+## 
+## $tblLURelationshipPath
+## data frame with 0 columns and 0 rows
+## 
+## $tblLURaceCohort
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUMultipleBirth
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUMarkerType
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUMarkerEvidence
+## data frame with 0 columns and 0 rows
+## 
+## $tblLUExtractSource
+## data frame with 0 columns and 0 rows
+## 
+## $tblitem
+## data frame with 0 columns and 0 rows
 
# d <- ds_file %>%
@@ -1137,40 +1270,51 @@
 # RODBC::sqlSave(channel, dat=d, tablename="Enum.tblLURosterGen1", safer=TRUE, rownames=FALSE, append=TRUE)
 
 # Upload metadata tables
-purrr::map2_int(
-  ds_file$entries,
-  ds_file$table_name,
-  function( d, table_name ) {
+purrr::pmap_int(
+  list(
+    ds_file$entries,
+    ds_file$table_name,
+    ds_file$schema_name
+  ),
+  function( d, table_name, schema_name ) {
+    # browser()
+    # DBI::dbWriteTable(
+    #   conn    = channel,
+    #   name    = table_name,
+    #   schema  = schema_name,
+    #   value   = d,
+    #   append  = F
+    # )
     RODBC::sqlSave(
-      channel     = channel,
+      channel     = channel_rodbc,
       dat         = d,
-      tablename   = table_name,
+      # tablename   = table_name,
+      tablename   = paste0(schema_name, ".", table_name),
       safer       = TRUE,       # Don't keep the existing table.
       rownames    = FALSE,
       append      = TRUE
     )
   }
-) %>%
-purrr::set_names(ds_file$table_name)
+) #%>%
 
-
##                 Metadata.tblItem          Enum.tblLUExtractSource 
-##                                1                                1 
-##         Enum.tblLUMarkerEvidence             Enum.tblLUMarkerType 
-##                                1                                1 
-##          Enum.tblLUMultipleBirth             Enum.tblLURaceCohort 
-##                                1                                1 
-##       Enum.tblLURelationshipPath             Enum.tblLURosterGen1 
-##                                1                                1 
-##           Enum.tblLUSurveySource               Enum.tblLUTristate 
-##                                1                                1 
-##                  Enum.tblLUYesNo             Metadata.tblMzManual 
-##                                1                                1 
-## Metadata.tblRosterGen1Assignment             Metadata.tblVariable 
-##                                1                                1
+
##  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 
-
# for( i in seq_len(nrow(ds_file)) ) {
+
# purrr::set_names(ds_file$table_name)
+# a <- ds_file$entries[[15]]
+# table(a$ID)
+
+# odbc::dbWriteTable(
+#   conn    = channel,
+#   name    = DBI::SQL("Metadata.tblvariable_97"),
+#   # name    = "tblvariable_97",
+#   # schema  = "Metadata",
+#   value   = ds_file$entries[[16]],
+#   append  = T
+# )
+
+# for( i in seq_len(nrow(ds_file)) ) {
 #   message(glue::glue("Uploading from `{ basename(ds_file$path)[i]}` to `{ds_file$table_name[i]}`."))
 #
 #   d <- ds_file$entries[[i]]
@@ -1212,7 +1356,8 @@
 # }
 
 # Close channel
-RODBC::odbcClose(channel); rm(channel)
+DBI::dbDisconnect(channel); rm(channel)
+RODBC::odbcClose(channel_rodbc); rm(channel_rodbc)
 

The R session information (including the OS info, R version and all @@ -1221,7 +1366,7 @@

sessionInfo()
 
-
## R version 3.4.2 Patched (2017-10-08 r73502)
+
## R version 3.4.3 Patched (2017-12-05 r73849)
 ## Platform: x86_64-w64-mingw32/x64 (64-bit)
 ## Running under: Windows >= 8 x64 (build 9200)
 ## 
@@ -1241,25 +1386,27 @@
 ## [1] bindrcpp_0.2 magrittr_1.5
 ## 
 ## loaded via a namespace (and not attached):
-##  [1] Rcpp_0.12.13          knitr_1.17            bindr_0.1            
-##  [4] devtools_1.13.3       hms_0.3               testit_0.7           
-##  [7] munsell_0.4.3         colorspace_1.3-2      R6_2.2.2             
-## [10] rlang_0.1.2.9000      highr_0.6             plyr_1.8.4           
-## [13] stringr_1.2.0         dplyr_0.7.4           tools_3.4.2          
-## [16] checkmate_1.8.4-9000  withr_2.0.0           htmltools_0.3.6      
-## [19] yaml_2.1.14           rprojroot_1.2         digest_0.6.12        
-## [22] assertthat_0.2.0      tibble_1.3.4          purrr_0.2.3          
-## [25] tidyr_0.7.1           readr_1.1.1           RODBC_1.3-15         
-## [28] rsconnect_0.8.5       OuhscMunge_0.1.8.9004 memoise_1.1.0        
-## [31] glue_1.1.1            evaluate_0.10.1       rmarkdown_1.6        
-## [34] stringi_1.1.5         compiler_3.4.2        scales_0.5.0.9000    
-## [37] backports_1.1.1       markdown_0.8          pkgconfig_2.0.1
+##  [1] Rcpp_0.12.14          highr_0.6             plyr_1.8.4           
+##  [4] pillar_1.0.1          compiler_3.4.3        bindr_0.1            
+##  [7] tools_3.4.3           odbc_1.1.3            digest_0.6.13        
+## [10] bit_1.1-12            evaluate_0.10.1       tibble_1.4.1         
+## [13] checkmate_1.8.5       pkgconfig_2.0.1       rlang_0.1.6          
+## [16] DBI_0.7               cli_1.0.0             rstudioapi_0.7       
+## [19] yaml_2.1.16           dplyr_0.7.4           stringr_1.2.0        
+## [22] knitr_1.18            hms_0.4.0             bit64_0.9-7          
+## [25] rprojroot_1.3-1       glue_1.2.0            OuhscMunge_0.1.8.9005
+## [28] R6_2.2.2              rmarkdown_1.8         tidyr_0.7.2          
+## [31] readr_1.1.1           purrr_0.2.4           blob_1.1.0           
+## [34] scales_0.5.0.9000     backports_1.1.2       RODBC_1.3-15         
+## [37] htmltools_0.3.6       rsconnect_0.8.5       assertthat_0.2.0     
+## [40] testit_0.7.1          colorspace_1.3-2      utf8_1.1.2           
+## [43] stringi_1.1.6         munsell_0.4.3         crayon_1.3.4
 
Sys.time()
 
-
## [1] "2017-10-17 13:52:35 CDT"
+
## [1] "2018-01-04 01:32:24 CST"
 
diff --git a/stitched-output/dal/import-metadata.md b/stitched-output/dal/import-metadata.md index 10b1879..038a212 100644 --- a/stitched-output/dal/import-metadata.md +++ b/stitched-output/dal/import-metadata.md @@ -3,11 +3,11 @@ This report was automatically generated with the R package **knitr** -(version 1.17). +(version 1.18). ```r -# knitr::stitch_rmd(script="./dal/import-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T) +# knitr::stitch_rmd(script="./dal/import-79-metadata.R", output="./stitched-output/dal/import-metadata.md") # dir.create(output="./stitched-output/dal/", recursive=T) rm(list=ls(all=TRUE)) #Clear the variables from previous runs. ``` @@ -28,11 +28,12 @@ requireNamespace("purrr" ) requireNamespace("dplyr" ) #Avoid attaching dplyr, b/c its function names conflict with a lot of packages (esp base, stats, and plyr). requireNamespace("testit" ) #For asserting conditions meet expected patterns. requireNamespace("RODBC" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. +requireNamespace("odbc" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. ``` ```r # Constant values that won't change. -directory_in <- "data-public/metadata/tables" +directory_in <- "data-public/metadata/tables-79" col_types_minimal <- readr::cols_only( ID = readr::col_integer(), @@ -45,7 +46,7 @@ col_types_minimal <- readr::cols_only( # - Tables are WRITTEN from top to bottom. # - Tables are DELETED from bottom to top. lst_col_types <- list( - Item = readr::cols_only( + item = readr::cols_only( ID = readr::col_integer(), Label = readr::col_character(), MinValue = readr::col_integer(), @@ -54,6 +55,15 @@ lst_col_types <- list( Active = readr::col_logical(), Notes = readr::col_character() ), + # item_97 = readr::cols_only( + # ID = readr::col_integer(), + # Label = readr::col_character(), + # MinValue = readr::col_integer(), + # MinNonnegative = readr::col_integer(), + # MaxValue = readr::col_integer(), + # Active = readr::col_logical(), + # Notes = readr::col_character() + # ), LUExtractSource = col_types_minimal, LUMarkerEvidence = col_types_minimal, LUMarkerType = readr::cols_only( @@ -125,8 +135,8 @@ lst_col_types <- list( ResponseLowerLabel = readr::col_character(), ResponseUpperLabel = readr::col_character() ), - Variable = readr::cols_only( - ID = readr::col_integer(), + variable = readr::cols_only( + # ID = readr::col_integer(), VariableCode = readr::col_character(), Item = readr::col_integer(), Generation = readr::col_integer(), @@ -136,9 +146,22 @@ lst_col_types <- list( LoopIndex = readr::col_integer(), Translate = readr::col_integer(), Notes = readr::col_character(), - Active = readr::col_logical(), + Active = readr::col_integer(), Notes = readr::col_character() ) + # variable_97 = readr::cols_only( + # # ID = readr::col_integer(), + # VariableCode = readr::col_character(), + # Item = readr::col_integer(), + # Generation = readr::col_integer(), + # ExtractSource = readr::col_integer(), + # SurveySource = readr::col_integer(), + # SurveyYear = readr::col_integer(), + # LoopIndex = readr::col_integer(), + # Translate = readr::col_integer(), + # Active = readr::col_integer(), + # Notes = readr::col_character() + # ) ) col_types_mapping <- readr::cols_only( @@ -157,25 +180,26 @@ ds_mapping ``` ``` -## # A tibble: 15 x 5 -## table_name schema_name enum_name c_sharp_type -## -## 1 Item Metadata Item short -## 2 LUExtractSource Enum ExtractSource byte -## 3 LUGender Enum Gender byte -## 4 LUMarkerEvidence Enum MarkerEvidence byte -## 5 LUMarkerType Enum MarkerType byte -## 6 LUMultipleBirth Enum MultipleBirth byte -## 7 LURaceCohort Enum RaceCohort byte -## 8 LURelationshipPath Enum RelationshipPath byte -## 9 LURosterGen1 Enum RosterGen1 short -## 10 LUSurveySource Enum SurveySource byte -## 11 LUTristate Enum Tristate byte -## 12 LUYesNo Enum YesNo short -## 13 MzManual Metadata NA_character NA_character -## 14 RosterGen1Assignment Metadata NA_character NA_character -## 15 Variable Metadata NA_character NA_character -## # ... with 1 more variables: convert_to_enum +## # A tibble: 17 x 5 +## table_name schema_name enum_name c_sharp_type convert~ +## +## 1 item Metadata item short T +## 2 #item_97 Metadata item_97 short T +## 3 LUExtractSource Enum ExtractSource byte T +## 4 LUGender Enum Gender byte T +## 5 LUMarkerEvidence Enum MarkerEvidence byte T +## 6 LUMarkerType Enum MarkerType byte T +## 7 LUMultipleBirth Enum MultipleBirth byte T +## 8 LURaceCohort Enum RaceCohort byte T +## 9 LURelationshipPath Enum RelationshipPath byte T +## 10 LURosterGen1 Enum RosterGen1 short T +## 11 LUSurveySource Enum SurveySource byte T +## 12 LUTristate Enum Tristate byte T +## 13 LUYesNo Enum YesNo short T +## 14 MzManual Metadata NA_character NA_character F +## 15 RosterGen1Assignment Metadata NA_character NA_character F +## 16 variable Metadata NA_character NA_character F +## 17 #variable_97 Metadata NA_character NA_character F ``` ```r @@ -192,59 +216,60 @@ ds_file ``` ## # A tibble: 14 x 4 -## name -## -## 1 Item -## 2 LUExtractSource -## 3 LUMarkerEvidence -## 4 LUMarkerType -## 5 LUMultipleBirth -## 6 LURaceCohort -## 7 LURelationshipPath -## 8 LURosterGen1 -## 9 LUSurveySource -## 10 LUTristate -## 11 LUYesNo -## 12 MzManual -## 13 RosterGen1Assignment -## 14 Variable -## # ... with 3 more variables: path , col_types , exists +## name path col_types exis~ +## +## 1 item data-public/metadata/tables-79/i~ % + # dplyr::slice(15) %>% dplyr::select(name, path, col_types) %>% dplyr::mutate( - entries = purrr::pmap(list(file=.$path, col_types=.$col_types), readr::read_csv) + entries = purrr::pmap(list(file=.$path, col_types=.$col_types), readr::read_csv, comment = "#") ) ds_entries ``` ``` ## # A tibble: 14 x 4 -## name -## -## 1 Item -## 2 LUExtractSource -## 3 LUMarkerEvidence -## 4 LUMarkerType -## 5 LUMultipleBirth -## 6 LURaceCohort -## 7 LURelationshipPath -## 8 LURosterGen1 -## 9 LUSurveySource -## 10 LUTristate -## 11 LUYesNo -## 12 MzManual -## 13 RosterGen1Assignment -## 14 Variable -## # ... with 3 more variables: path , col_types , entries +## name path col_types entries +## +## 1 item data-public/metadata/table~ % dplyr::left_join( ds_mapping, by=c("name"="table_name")) %>% dplyr::mutate( - table_name = paste0(schema_name, ".tbl", name), - sql_delete = paste0("DELETE FROM ", table_name) + table_name = paste0("tbl", name), + sql_delete = glue::glue("DELETE FROM {schema_name}.{table_name};") + # table_name = paste0(schema_name, ".tbl", name), + # sql_delete = paste0("DELETE FROM ", table_name) ) %>% dplyr::left_join( ds_entries %>% @@ -330,165 +359,162 @@ ds_file$entries %>% ``` ## # A tibble: 110 x 7 -## ID Label MinValue MinNonnegative -## -## 1 1 IDOfOther1979RosterGen1 -4 1 -## 2 2 RosterGen1979 -4 1 -## 3 3 SiblingNumberFrom1993SiblingRoster -4 1 -## 4 4 IDCodeOfOtherSiblingGen1 -5 3 -## 5 5 ShareBiomomGen1 -5 0 -## 6 6 ShareBiodadGen1 -5 0 -## 7 9 IDCodeOfOtherInterviewedBiodadGen2 -7 1 -## 8 10 ShareBiodadGen2 -7 0 -## 9 11 Gen1MomOfGen2Subject 2 2 -## 10 13 DateOfBirthMonth -5 1 -## # ... with 100 more rows, and 3 more variables: MaxValue , -## # Active , Notes -## # A tibble: 11 x 4 -## ID Label Active Notes -## -## 1 3 Gen1Links TRUE -## 2 4 Gen2Links TRUE -## 3 5 Gen2LinksFromGen1 TRUE -## 4 6 Gen2ImplicitFather TRUE -## 5 7 Gen2FatherFromGen1 TRUE -## 6 8 Gen1Outcomes TRUE -## 7 9 Gen2OutcomesHeight TRUE -## 8 10 Gen1Explicit TRUE -## 9 11 Gen1Implicit TRUE -## 10 12 Gen2OutcomesWeight TRUE -## 11 13 Gen2OutcomesMath TRUE +## ID Label MinVa~ MinN~ MaxV~ Acti~ Notes +## +## 1 1 IDOfOther1979RosterGen1 -4 1 12557 T +## 2 2 RosterGen1979 -4 1 66 T +## 3 3 SiblingNumberFrom1993SiblingRoster -4 1 99 T +## 4 4 IDCodeOfOtherSiblingGen1 -5 3 12518 T +## 5 5 ShareBiomomGen1 -5 0 2 T +## 6 6 ShareBiodadGen1 -5 0 2 T +## 7 9 IDCodeOfOtherInterviewedBiodadGen2 -7 1 11 T +## 8 10 ShareBiodadGen2 -7 0 3 T +## 9 11 Gen1MomOfGen2Subject 2 2 12675 T +## 10 13 DateOfBirthMonth -5 1 12 T +## # ... with 100 more rows +## # A tibble: 12 x 4 +## ID Label Active Notes +## +## 1 3 Gen1Links T +## 2 4 Gen2Links T +## 3 5 Gen2LinksFromGen1 T +## 4 6 Gen2ImplicitFather T +## 5 7 Gen2FatherFromGen1 T +## 6 8 Gen1Outcomes T +## 7 9 Gen2OutcomesHeight T +## 8 10 Gen1Explicit T +## 9 11 Gen1Implicit T +## 10 12 Gen2OutcomesWeight T +## 11 13 Gen2OutcomesMath T +## 12 100 gen_1_97_roster T ## # A tibble: 8 x 4 -## ID Label Active Notes -## -## 1 0 Irrelevant TRUE -## 2 1 StronglySupports TRUE -## 3 2 Supports TRUE -## 4 3 Consistent TRUE -## 5 4 Ambiguous TRUE -## 6 5 Missing TRUE -## 7 6 Unlikely TRUE -## 8 7 Disconfirms TRUE +## ID Label Active Notes +## +## 1 0 Irrelevant T +## 2 1 StronglySupports T +## 3 2 Supports T +## 4 3 Consistent T +## 5 4 Ambiguous T +## 6 5 Missing T +## 7 6 Unlikely T +## 8 7 Disconfirms T ## # A tibble: 28 x 5 -## ID Label Explicit Active Notes -## -## 1 1 RosterGen1 1 TRUE -## 2 2 ShareBiomom 1 TRUE -## 3 3 ShareBiodad 1 TRUE -## 4 5 DobSeparation 0 TRUE -## 5 6 GenderAgreement 0 TRUE -## 6 10 FatherAsthma 0 TRUE -## 7 11 BabyDaddyAsthma 0 TRUE -## 8 12 BabyDaddyLeftHHDate 0 TRUE -## 9 13 BabyDaddyDeathDate 0 TRUE -## 10 14 BabyDaddyAlive 0 TRUE +## ID Label Explicit Active Notes +## +## 1 1 RosterGen1 1 T +## 2 2 ShareBiomom 1 T +## 3 3 ShareBiodad 1 T +## 4 5 DobSeparation 0 T +## 5 6 GenderAgreement 0 T +## 6 10 FatherAsthma 0 T +## 7 11 BabyDaddyAsthma 0 T +## 8 12 BabyDaddyLeftHHDate 0 T +## 9 13 BabyDaddyDeathDate 0 T +## 10 14 BabyDaddyAlive 0 T ## # ... with 18 more rows ## # A tibble: 5 x 4 -## ID Label Active -## -## 1 0 No TRUE -## 2 2 Twin TRUE -## 3 3 Trip TRUE -## 4 4 TwinOrTrip TRUE -## 5 255 DoNotKnow TRUE -## # ... with 1 more variables: Notes +## ID Label Active Notes +## +## 1 0 No T +## 2 2 Twin T +## 3 3 Trip T +## 4 4 TwinOrTrip T Currently Then Gen1 algorithm doesn't distingui~ +## 5 255 DoNotKnow T ## # A tibble: 3 x 4 -## ID Label Active Notes -## -## 1 1 Hispanic TRUE -## 2 2 Black TRUE -## 3 3 Nbnh TRUE +## ID Label Active Notes +## +## 1 1 Hispanic T +## 2 2 Black T +## 3 3 Nbnh T ## # A tibble: 5 x 4 -## ID Label Active Notes -## -## 1 1 Gen1Housemates TRUE -## 2 2 Gen2Siblings TRUE -## 3 3 Gen2Cousins TRUE -## 4 4 ParentChild TRUE -## 5 5 AuntNiece TRUE Acutally (Uncle|Aunt)-(Nephew|Niece) +## ID Label Active Notes +## +## 1 1 Gen1Housemates T +## 2 2 Gen2Siblings T +## 3 3 Gen2Cousins T +## 4 4 ParentChild T +## 5 5 AuntNiece T Actually (Uncle|Aunt)-(Nephew|Niece) ## # A tibble: 67 x 4 -## ID Label Active Notes -## -## 1 -4 ValidSkip TRUE -## 2 -3 InvalidSkip TRUE -## 3 -1 Refusal TRUE -## 4 0 Respondent TRUE -## 5 1 Spouse TRUE -## 6 2 Son TRUE -## 7 3 Daughter TRUE -## 8 4 Father TRUE -## 9 5 Mother TRUE -## 10 6 Brother TRUE +## ID Label Active Notes +## +## 1 -4 ValidSkip T +## 2 -3 InvalidSkip T +## 3 -1 Refusal T +## 4 0 Respondent T +## 5 1 Spouse T +## 6 2 Son T +## 7 3 Daughter T +## 8 4 Father T +## 9 5 Mother T +## 10 6 Brother T ## # ... with 57 more rows -## # A tibble: 4 x 4 -## ID Label Active Notes -## -## 1 0 NoInterview TRUE -## 2 1 Gen1 TRUE -## 3 2 Gen2C TRUE -## 4 3 Gen2YA TRUE +## # A tibble: 5 x 4 +## ID Label Active Notes +## +## 1 0 NoInterview T +## 2 1 Gen1 T +## 3 2 Gen2C T +## 4 3 Gen2YA T +## 5 4 97 T ## # A tibble: 3 x 4 -## ID Label Active Notes -## -## 1 0 No TRUE -## 2 1 Yes TRUE -## 3 255 DoNotKnow TRUE +## ID Label Active Notes +## +## 1 0 No T +## 2 1 Yes T +## 3 255 DoNotKnow T ## # A tibble: 6 x 4 -## ID Label Active Notes -## -## 1 -6 ValidSkipOrNoInterviewOrNotInSurvey TRUE -## 2 -3 InvalidSkip TRUE -## 3 -2 DoNotKnow TRUE -## 4 -1 Refusal TRUE -## 5 0 No TRUE -## 6 1 Yes TRUE +## ID Label Active Notes +## +## 1 -6 ValidSkipOrNoInterviewOrNotInSurvey T +## 2 -3 InvalidSkip T +## 3 -2 DoNotKnow T +## 4 -1 Refusal T +## 5 0 No T +## 6 1 Yes T ## # A tibble: 208 x 9 -## ID SubjectTag_S1 SubjectTag_S2 Generation MultipleBirthIfSameSex -## -## 1 1 5003 5004 2 2 -## 2 3 14303 14304 2 2 -## 3 5 15904 15905 2 2 -## 4 6 28805 28806 2 2 -## 5 8 36504 36505 2 2 -## 6 9 67703 67704 2 2 -## 7 10 73301 73302 2 2 -## 8 12 74301 74302 2 2 -## 9 13 77502 77503 2 2 -## 10 14 93001 93002 2 2 -## # ... with 198 more rows, and 4 more variables: IsMz , -## # Undecided , Related , Notes +## ID SubjectTag_S1 SubjectTag_S2 Gener~ Multi~ IsMz Unde~ Rela~ Notes +## +## 1 1 5003 5004 2 2 0 0 1 Very~ +## 2 3 14303 14304 2 2 0 0 1 Diff~ +## 3 5 15904 15905 2 2 0 0 1 +## 4 6 28805 28806 2 2 0 0 1 Diff~ +## 5 8 36504 36505 2 2 1 0 1 Twic~ +## 6 9 67703 67704 2 2 0 0 1 1994~ +## 7 10 73301 73302 2 2 1 0 1 Most~ +## 8 12 74301 74302 2 2 0 0 1 Diff~ +## 9 13 77502 77503 2 2 1 0 1 1994~ +## 10 14 93001 93002 2 2 1 0 1 1994~ +## # ... with 198 more rows ## # A tibble: 50 x 16 -## ID ResponseLower ResponseUpper Freq Resolved R RBoundLower -## -## 1 1 -3 -3 67 0 NA 0.000 -## 2 2 -3 -1 11 0 NA 0.000 -## 3 3 -3 33 6 1 0.000 0.000 -## 4 4 -3 36 35 1 0.000 0.000 -## 5 5 -1 18 1 1 0.125 0.125 -## 6 6 -1 36 3 1 0.000 0.000 -## 7 7 1 1 167 1 0.000 0.000 -## 8 8 1 33 1 1 0.000 0.000 -## 9 9 1 36 1 1 0.000 0.000 -## 10 10 1 57 1 1 0.000 0.000 -## # ... with 40 more rows, and 9 more variables: RBoundUpper , -## # SameGeneration , ShareBiodad , ShareBiomom , -## # ShareBiograndparent , Inconsistent , Notes , -## # ResponseLowerLabel , ResponseUpperLabel -## # A tibble: 1,575 x 11 -## ID VariableCode Item Generation ExtractSource SurveySource -## -## 1 1 R0000149 101 1 3 1 -## 2 2 R0216500 16 1 3 1 -## 3 3 R0406510 16 1 3 1 -## 4 4 R0619010 16 1 3 1 -## 5 5 R0898310 16 1 3 1 -## 6 6 R1145110 16 1 3 1 -## 7 7 R1520310 16 1 3 1 -## 8 8 R1891010 16 1 3 1 -## 9 9 R2258110 16 1 3 1 -## 10 10 R2445510 16 1 3 1 -## # ... with 1,565 more rows, and 5 more variables: SurveyYear , -## # LoopIndex , Translate , Active , Notes +## ID Respo~ Respo~ Freq Resol~ R RBoun~ RBoun~ Same~ Shar~ Shar~ +## +## 1 1 -3 - 3 67 0 NA 0 1.00 255 255 255 +## 2 2 -3 - 1 11 0 NA 0 1.00 255 255 255 +## 3 3 -3 33 6 1 0 0 0 1 0 0 +## 4 4 -3 36 35 1 0 0 0 255 0 0 +## 5 5 -1 18 1 1 0.125 0.125 0.125 0 0 0 +## 6 6 -1 36 3 1 0 0 0 255 0 0 +## 7 7 1 1 167 1 0 0 0 1 0 0 +## 8 8 1 33 1 1 0 0 0 1 0 0 +## 9 9 1 36 1 1 0 0 0 1 0 0 +## 10 10 1 57 1 1 0 0 0 1 0 0 +## # ... with 40 more rows, and 5 more variables: ShareBiograndparent , +## # Inconsistent , Notes , ResponseLowerLabel , +## # ResponseUpperLabel +## # A tibble: 1,642 x 10 +## VariableCode Item Generation Extr~ Surv~ Surv~ Loop~ Tran~ Acti~ Notes +## +## 1 R0000100 100 1 3 1 1979 0 0 1 Is r~ +## 2 C0000100 100 2 6 2 0 0 0 1 Is r~ +## 3 R0000149 101 1 3 1 1979 0 0 1 Is r~ +## 4 R0214800 102 1 3 1 1979 0 0 1 Is r~ +## 5 C0005400 102 2 4 2 0 0 0 1 Is r~ +## 6 R0214700 103 1 3 1 1979 0 1 1 No m~ +## 7 C0005300 103 2 4 2 0 0 1 1 no m~ +## 8 R0000150 1 1 10 1 1979 1 1 1 +## 9 R0000152 1 1 10 1 1979 2 1 1 +## 10 R0000154 1 1 10 1 1979 3 1 1 +## # ... with 1,632 more rows ``` ```r @@ -515,13 +541,13 @@ ds_file$table_name ``` ``` -## [1] "Metadata.tblItem" "Enum.tblLUExtractSource" -## [3] "Enum.tblLUMarkerEvidence" "Enum.tblLUMarkerType" -## [5] "Enum.tblLUMultipleBirth" "Enum.tblLURaceCohort" -## [7] "Enum.tblLURelationshipPath" "Enum.tblLURosterGen1" -## [9] "Enum.tblLUSurveySource" "Enum.tblLUTristate" -## [11] "Enum.tblLUYesNo" "Metadata.tblMzManual" -## [13] "Metadata.tblRosterGen1Assignment" "Metadata.tblVariable" +## [1] "tblitem" "tblLUExtractSource" +## [3] "tblLUMarkerEvidence" "tblLUMarkerType" +## [5] "tblLUMultipleBirth" "tblLURaceCohort" +## [7] "tblLURelationshipPath" "tblLURosterGen1" +## [9] "tblLUSurveySource" "tblLUTristate" +## [11] "tblLUYesNo" "tblMzManual" +## [13] "tblRosterGen1Assignment" "tblvariable" ``` ```r @@ -530,26 +556,22 @@ ds_file ``` ## # A tibble: 14 x 11 -## name -## -## 1 Item -## 2 LUExtractSource -## 3 LUMarkerEvidence -## 4 LUMarkerType -## 5 LUMultipleBirth -## 6 LURaceCohort -## 7 LURelationshipPath -## 8 LURosterGen1 -## 9 LUSurveySource -## 10 LUTristate -## 11 LUYesNo -## 12 MzManual -## 13 RosterGen1Assignment -## 14 Variable -## # ... with 10 more variables: path , col_types , exists , -## # schema_name , enum_name , c_sharp_type , -## # convert_to_enum , table_name , sql_delete , -## # entries +## name path col_t~ exists sche~ enum~ c_sh~ conv~ tabl~ sql_d~ entr~ +## +## 1 item data-p~ % ``` ## -## public enum Item { +## public enum item { ## IDOfOther1979RosterGen1 = 1, ## RosterGen1979 = 2, ## SiblingNumberFrom1993SiblingRoster = 3, @@ -708,6 +730,7 @@ ds_enum %>% ## Gen1Implicit = 11, ## Gen2OutcomesWeight = 12, ## Gen2OutcomesMath = 13, +## gen_1_97_roster = 100, ## } ## ## public enum MarkerEvidence { @@ -771,7 +794,7 @@ ds_enum %>% ## Gen2Siblings = 2, ## Gen2Cousins = 3, ## ParentChild = 4, -## AuntNiece = 5, // Acutally (Uncle|Aunt)-(Nephew|Niece) +## AuntNiece = 5, // Actually (Uncle|Aunt)-(Nephew|Niece) ## } ## ## public enum RosterGen1 { @@ -849,6 +872,7 @@ ds_enum %>% ## Gen1 = 1, ## Gen2C = 2, ## Gen2YA = 3, +## 97 = 4, ## } ## ## public enum Tristate { @@ -890,20 +914,69 @@ ds_enum %>% ds_table_process <- ds_table %>% dplyr::filter(schema_name == "Process") %>% dplyr::mutate( - #sql_truncate = glue::glue("TRUNCATE TABLE {schema_name}.{table_name};") + # sql_truncate = glue::glue("TRUNCATE TABLE {schema_name}.{table_name};") sql_truncate = glue::glue("DELETE FROM {schema_name}.{table_name};") ) # Open channel -channel <- open_dsn_channel() -RODBC::odbcGetInfo(channel) +channel <- open_dsn_channel_odbc() +DBI::dbGetInfo(channel) +``` + +``` +## $dbname +## [1] "NlsyLinks79" +## +## $dbms.name +## [1] "Microsoft SQL Server" +## +## $db.version +## [1] "13.00.4206" +## +## $username +## [1] "dbo" +## +## $host +## [1] "" +## +## $port +## [1] "" +## +## $sourcename +## [1] "local-nlsy-links-79" +## +## $servername +## [1] "GIMBLE\\EXPRESS_2016" +## +## $drivername +## [1] "msodbcsql13.dll" +## +## $odbc.version +## [1] "03.80.0000" +## +## $driver.version +## [1] "14.00.0500" +## +## $odbcdriver.version +## [1] "03.80" +## +## $supports.transactions +## [1] TRUE +## +## attr(,"class") +## [1] "Microsoft SQL Server" "driver_info" "list" +``` + +```r +channel_rodbc <- open_dsn_channel_rodbc() +RODBC::odbcGetInfo(channel_rodbc) ``` ``` ## DBMS_Name DBMS_Ver Driver_ODBC_Ver ## "Microsoft SQL Server" "13.00.4206" "03.80" ## Data_Source_Name Driver_Name Driver_Ver -## "local-nlsy-links" "msodbcsql13.dll" "14.00.0500" +## "local-nlsy-links-79" "msodbcsql13.dll" "14.00.0500" ## ODBC_Ver Server_Name ## "03.80.0000" "GIMBLE\\EXPRESS_2016" ``` @@ -911,51 +984,113 @@ RODBC::odbcGetInfo(channel) ```r # Clear process tables delete_results_process <- ds_table_process$sql_truncate %>% - rev() %>% purrr::set_names(ds_table_process$table_name) %>% - purrr::map_int(RODBC::sqlQuery, channel=channel, errors=FALSE) + rev() %>% + purrr::map(DBI::dbGetQuery, conn=channel) delete_results_process ``` ``` -## tblBabyDaddy tblFatherOfGen2 tblIRDemo1 -## -1 -1 -1 -## tblMarkerGen1 tblMarkerGen2 tblOutcome -## -1 -1 -1 -## tblParentsOfGen1Current tblParentsOfGen1Retro tblRelatedStructure -## -1 -1 -1 -## tblRelatedValues tblResponse tblRosterGen1 -## -1 -1 -1 -## tblSubject tblSubjectDetails tblSurveyTime -## -1 -1 -1 +## $tblSurveyTime +## data frame with 0 columns and 0 rows +## +## $tblSubjectDetails +## data frame with 0 columns and 0 rows +## +## $tblSubject +## data frame with 0 columns and 0 rows +## +## $tblRosterGen1 +## data frame with 0 columns and 0 rows +## +## $tblResponse +## data frame with 0 columns and 0 rows +## +## $tblRelatedValues +## data frame with 0 columns and 0 rows +## +## $tblRelatedStructure +## data frame with 0 columns and 0 rows +## +## $tblParentsOfGen1Retro +## data frame with 0 columns and 0 rows +## +## $tblParentsOfGen1Current +## data frame with 0 columns and 0 rows +## +## $tblOutcome +## data frame with 0 columns and 0 rows +## +## $tblMarkerGen2 +## data frame with 0 columns and 0 rows +## +## $tblMarkerGen1 +## data frame with 0 columns and 0 rows +## +## $tblIRDemo1 +## data frame with 0 columns and 0 rows +## +## $tblFatherOfGen2 +## data frame with 0 columns and 0 rows +## +## $tblBabyDaddy +## data frame with 0 columns and 0 rows ``` ```r # Delete metadata tables # delete_result <- RODBC::sqlQuery(channel, "DELETE FROM [NlsLinks].[Metadata].[tblVariable]", errors=FALSE) delete_results_metadata <- ds_file$sql_delete %>% - rev() %>% purrr::set_names(ds_file$table_name) %>% - purrr::map_int(RODBC::sqlQuery, channel=channel, errors=FALSE) + rev() %>% + purrr::map(DBI::dbGetQuery, conn=channel) +# DBI::dbGetQuery(conn=channel, ds_file$sql_delete[15]) delete_results_metadata ``` ``` -## Metadata.tblItem Enum.tblLUExtractSource -## -2 -2 -## Enum.tblLUMarkerEvidence Enum.tblLUMarkerType -## -2 -2 -## Enum.tblLUMultipleBirth Enum.tblLURaceCohort -## -2 -2 -## Enum.tblLURelationshipPath Enum.tblLURosterGen1 -## -2 -2 -## Enum.tblLUSurveySource Enum.tblLUTristate -## -2 -2 -## Enum.tblLUYesNo Metadata.tblMzManual -## -2 -2 -## Metadata.tblRosterGen1Assignment Metadata.tblVariable -## -2 -2 +## $tblvariable +## data frame with 0 columns and 0 rows +## +## $tblRosterGen1Assignment +## data frame with 0 columns and 0 rows +## +## $tblMzManual +## data frame with 0 columns and 0 rows +## +## $tblLUYesNo +## data frame with 0 columns and 0 rows +## +## $tblLUTristate +## data frame with 0 columns and 0 rows +## +## $tblLUSurveySource +## data frame with 0 columns and 0 rows +## +## $tblLURosterGen1 +## data frame with 0 columns and 0 rows +## +## $tblLURelationshipPath +## data frame with 0 columns and 0 rows +## +## $tblLURaceCohort +## data frame with 0 columns and 0 rows +## +## $tblLUMultipleBirth +## data frame with 0 columns and 0 rows +## +## $tblLUMarkerType +## data frame with 0 columns and 0 rows +## +## $tblLUMarkerEvidence +## data frame with 0 columns and 0 rows +## +## $tblLUExtractSource +## data frame with 0 columns and 0 rows +## +## $tblitem +## data frame with 0 columns and 0 rows ``` ```r @@ -969,41 +1104,52 @@ delete_results_metadata # RODBC::sqlSave(channel, dat=d, tablename="Enum.tblLURosterGen1", safer=TRUE, rownames=FALSE, append=TRUE) # Upload metadata tables -purrr::map2_int( - ds_file$entries, - ds_file$table_name, - function( d, table_name ) { +purrr::pmap_int( + list( + ds_file$entries, + ds_file$table_name, + ds_file$schema_name + ), + function( d, table_name, schema_name ) { + # browser() + # DBI::dbWriteTable( + # conn = channel, + # name = table_name, + # schema = schema_name, + # value = d, + # append = F + # ) RODBC::sqlSave( - channel = channel, + channel = channel_rodbc, dat = d, - tablename = table_name, + # tablename = table_name, + tablename = paste0(schema_name, ".", table_name), safer = TRUE, # Don't keep the existing table. rownames = FALSE, append = TRUE ) } -) %>% -purrr::set_names(ds_file$table_name) +) #%>% ``` ``` -## Metadata.tblItem Enum.tblLUExtractSource -## 1 1 -## Enum.tblLUMarkerEvidence Enum.tblLUMarkerType -## 1 1 -## Enum.tblLUMultipleBirth Enum.tblLURaceCohort -## 1 1 -## Enum.tblLURelationshipPath Enum.tblLURosterGen1 -## 1 1 -## Enum.tblLUSurveySource Enum.tblLUTristate -## 1 1 -## Enum.tblLUYesNo Metadata.tblMzManual -## 1 1 -## Metadata.tblRosterGen1Assignment Metadata.tblVariable -## 1 1 +## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ``` ```r +# purrr::set_names(ds_file$table_name) +# a <- ds_file$entries[[15]] +# table(a$ID) + +# odbc::dbWriteTable( +# conn = channel, +# name = DBI::SQL("Metadata.tblvariable_97"), +# # name = "tblvariable_97", +# # schema = "Metadata", +# value = ds_file$entries[[16]], +# append = T +# ) + # for( i in seq_len(nrow(ds_file)) ) { # message(glue::glue("Uploading from `{ basename(ds_file$path)[i]}` to `{ds_file$table_name[i]}`.")) # @@ -1046,7 +1192,8 @@ purrr::set_names(ds_file$table_name) # } # Close channel -RODBC::odbcClose(channel); rm(channel) +DBI::dbDisconnect(channel); rm(channel) +RODBC::odbcClose(channel_rodbc); rm(channel_rodbc) ``` The R session information (including the OS info, R version and all @@ -1058,7 +1205,7 @@ sessionInfo() ``` ``` -## R version 3.4.2 Patched (2017-10-08 r73502) +## R version 3.4.3 Patched (2017-12-05 r73849) ## Platform: x86_64-w64-mingw32/x64 (64-bit) ## Running under: Windows >= 8 x64 (build 9200) ## @@ -1078,19 +1225,21 @@ sessionInfo() ## [1] bindrcpp_0.2 magrittr_1.5 ## ## loaded via a namespace (and not attached): -## [1] Rcpp_0.12.13 knitr_1.17 bindr_0.1 -## [4] devtools_1.13.3 hms_0.3 testit_0.7 -## [7] munsell_0.4.3 colorspace_1.3-2 R6_2.2.2 -## [10] rlang_0.1.2.9000 highr_0.6 plyr_1.8.4 -## [13] stringr_1.2.0 dplyr_0.7.4 tools_3.4.2 -## [16] checkmate_1.8.4-9000 withr_2.0.0 htmltools_0.3.6 -## [19] yaml_2.1.14 rprojroot_1.2 digest_0.6.12 -## [22] assertthat_0.2.0 tibble_1.3.4 purrr_0.2.3 -## [25] tidyr_0.7.1 readr_1.1.1 RODBC_1.3-15 -## [28] rsconnect_0.8.5 OuhscMunge_0.1.8.9004 memoise_1.1.0 -## [31] glue_1.1.1 evaluate_0.10.1 rmarkdown_1.6 -## [34] stringi_1.1.5 compiler_3.4.2 scales_0.5.0.9000 -## [37] backports_1.1.1 markdown_0.8 pkgconfig_2.0.1 +## [1] Rcpp_0.12.14 highr_0.6 plyr_1.8.4 +## [4] pillar_1.0.1 compiler_3.4.3 bindr_0.1 +## [7] tools_3.4.3 odbc_1.1.3 digest_0.6.13 +## [10] bit_1.1-12 evaluate_0.10.1 tibble_1.4.1 +## [13] checkmate_1.8.5 pkgconfig_2.0.1 rlang_0.1.6 +## [16] DBI_0.7 cli_1.0.0 rstudioapi_0.7 +## [19] yaml_2.1.16 dplyr_0.7.4 stringr_1.2.0 +## [22] knitr_1.18 hms_0.4.0 bit64_0.9-7 +## [25] rprojroot_1.3-1 glue_1.2.0 OuhscMunge_0.1.8.9005 +## [28] R6_2.2.2 rmarkdown_1.8 tidyr_0.7.2 +## [31] readr_1.1.1 purrr_0.2.4 blob_1.1.0 +## [34] scales_0.5.0.9000 backports_1.1.2 RODBC_1.3-15 +## [37] htmltools_0.3.6 rsconnect_0.8.5 assertthat_0.2.0 +## [40] testit_0.7.1 colorspace_1.3-2 utf8_1.1.2 +## [43] stringi_1.1.6 munsell_0.4.3 crayon_1.3.4 ``` ```r @@ -1098,6 +1247,6 @@ Sys.time() ``` ``` -## [1] "2017-10-17 13:52:35 CDT" +## [1] "2018-01-04 01:32:24 CST" ``` diff --git a/stitched-output/dal/import-raw.html b/stitched-output/dal/import-raw.html index 03d2d82..fdfce4f 100644 --- a/stitched-output/dal/import-raw.html +++ b/stitched-output/dal/import-raw.html @@ -224,6 +224,7 @@ requireNamespace("dplyr" ) #Avoid attaching dplyr, b/c its function names conflict with a lot of packages (esp base, stats, and plyr). requireNamespace("testit" ) #For asserting conditions meet expected patterns. requireNamespace("RODBC" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. +requireNamespace("odbc" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk.
# Constant values that won't change.
@@ -231,24 +232,24 @@
 columns_to_drop           <- c("A0002600", "Y2267000")
 
 ds_extract <- tibble::tribble(
-  ~table_name                       , ~file_name,
-  "Extract.tblGen1Explicit"         , "nlsy79-gen1/Gen1Explicit.csv",
-  "Extract.tblGen1Implicit"         , "nlsy79-gen1/Gen1Implicit.csv",
-  "Extract.tblGen1Links"            , "nlsy79-gen1/Gen1Links.csv",
-  "Extract.tblGen1Outcomes"         , "nlsy79-gen1/Gen1Outcomes.csv",
-  "Extract.tblGen1GeocodeSanitized" , "nlsy79-gen1/Gen1GeocodeSanitized.csv",
-  # "Process.tblLURosterGen1"         , "nlsy79-gen1/RosterGen1.csv",
-  # tblGen1MzDzDistinction2010
-  #
-  "Extract.tblGen2FatherFromGen1"   , "nlsy79-gen2/Gen2FatherFromGen1.csv",
-  "Extract.tblGen2ImplicitFather"   , "nlsy79-gen2/Gen2ImplicitFather.csv",
-  "Extract.tblGen2Links"            , "nlsy79-gen2/Gen2Links.csv",
-  "Extract.tblGen2LinksFromGen1"    , "nlsy79-gen2/Gen2LinksFromGen1.csv",
-  "Extract.tblGen2OutcomesHeight"   , "nlsy79-gen2/Gen2OutcomesHeight.csv",
-  "Extract.tblGen2OutcomesMath"     , "nlsy79-gen2/Gen2OutcomesMath.csv",
-  "Extract.tblGen2OutcomesWeight"   , "nlsy79-gen2/Gen2OutcomesWeight.csv",
-
-  "Extract.tbl97Roster"             , "nlsy97/97-roster.csv"
+  ~table_name                       , ~file_name
+  ,"Extract.tblGen1Explicit"         , "nlsy79-gen1/Gen1Explicit.csv"
+  ,"Extract.tblGen1Implicit"         , "nlsy79-gen1/Gen1Implicit.csv"
+  ,"Extract.tblGen1Links"            , "nlsy79-gen1/Gen1Links.csv"
+  ,"Extract.tblGen1Outcomes"         , "nlsy79-gen1/Gen1Outcomes.csv"
+  ,"Extract.tblGen1GeocodeSanitized" , "nlsy79-gen1/Gen1GeocodeSanitized.csv"
+  # # "Process.tblLURosterGen1"         , "nlsy79-gen1/RosterGen1.csv"
+  # # tblGen1MzDzDistinction2010
+  # #
+  ,"Extract.tblGen2FatherFromGen1"   , "nlsy79-gen2/Gen2FatherFromGen1.csv"
+  ,"Extract.tblGen2ImplicitFather"   , "nlsy79-gen2/Gen2ImplicitFather.csv"
+  ,"Extract.tblGen2Links"            , "nlsy79-gen2/Gen2Links.csv"
+  ,"Extract.tblGen2LinksFromGen1"    , "nlsy79-gen2/Gen2LinksFromGen1.csv"
+  ,"Extract.tblGen2OutcomesHeight"   , "nlsy79-gen2/Gen2OutcomesHeight.csv"
+  ,"Extract.tblGen2OutcomesMath"     , "nlsy79-gen2/Gen2OutcomesMath.csv"
+  ,"Extract.tblGen2OutcomesWeight"   , "nlsy79-gen2/Gen2OutcomesWeight.csv"
+
+  # "Extract.tbl97Roster"             , "nlsy97/97-roster.csv"
 )
 
 col_types_default <- readr::cols(
@@ -271,7 +272,7 @@
 print(ds_extract, n=20)
 
-
## # A tibble: 13 x 6
+
## # A tibble: 12 x 6
 ##    table_name                      file_n~ path     extra~ sql_se~ sql_tr~
 ##    <chr>                           <chr>   <chr>    <lgl>  <chr>   <chr>  
 ##  1 Extract.tblGen1Explicit         nlsy79~ data-un~ T      SELECT~ TRUNCA~
@@ -286,18 +287,17 @@
 ## 10 Extract.tblGen2OutcomesHeight   nlsy79~ data-un~ T      SELECT~ TRUNCA~
 ## 11 Extract.tblGen2OutcomesMath     nlsy79~ data-un~ T      SELECT~ TRUNCA~
 ## 12 Extract.tblGen2OutcomesWeight   nlsy79~ data-un~ T      SELECT~ TRUNCA~
-## 13 Extract.tbl97Roster             nlsy97~ data-un~ T      SELECT~ TRUNCA~
 
# Sniff out problems
 
-
channel <- open_dsn_channel_odbc()
-DBI::dbGetInfo(channel)
+
channel_odbc <- open_dsn_channel_odbc()
+DBI::dbGetInfo(channel_odbc)
 
## $dbname
-## [1] "NlsLinks"
+## [1] "NlsyLinks79"
 ## 
 ## $dbms.name
 ## [1] "Microsoft SQL Server"
@@ -315,7 +315,7 @@
 ## [1] ""
 ## 
 ## $sourcename
-## [1] "local-nlsy-links"
+## [1] "local-nlsy-links-79"
 ## 
 ## $servername
 ## [1] "GIMBLE\\EXPRESS_2016"
@@ -339,7 +339,9 @@
 ## [1] "Microsoft SQL Server" "driver_info"          "list"
 
-
for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L
+
channel_rodbc <- open_dsn_channel_rodbc()
+
+for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L
   message(glue::glue("Uploading from `{ds_extract$file_name[i]}` to `{ds_extract$table_name[i]}`."))
 
   d <- readr::read_csv(ds_extract$path[i], col_types=col_types_default)
@@ -358,13 +360,14 @@
   # purrr::map_chr(d, class)
   print(d, n=20)
 
-  #RODBC::sqlQuery(channel, ds_extract$sql_truncate[i], errors=FALSE)
-  # d_peek <- RODBC::sqlQuery(channel, ds_extract$sql_select[i], errors=FALSE)
+  #RODBC::sqlQuery(channel_odbc, ds_extract$sql_truncate[i], errors=FALSE)
+  # d_peek <- RODBC::sqlQuery(channel_odbc, ds_extract$sql_select[i], errors=FALSE)
 
-  DBI::dbGetQuery(channel, ds_extract$sql_truncate[i])
+  DBI::dbGetQuery(channel_odbc, ds_extract$sql_truncate[i])
 
-  # d_peek <- DBI::dbGetQuery(channel, ds_extract$sql_select[i])
-  peek <- DBI::dbListFields(channel, ds_extract$table_name[i])
+  d_peek <- DBI::dbGetQuery(channel_odbc, ds_extract$sql_select[i])
+  peek <- colnames(d_peek)
+  # peek <- DBI::dbListFields(channel_odbc, ds_extract$table_name[i])
 
   missing_in_extract    <- setdiff(peek       , colnames(d))
   missing_in_database   <- setdiff(colnames(d), peek       )
@@ -375,31 +378,32 @@
   # ) %>%
   #   dplyr::filter(db != extract)
 
-  system.time({
-  DBI::dbWriteTable(
-    conn    = channel,
-    name    = ds_extract$table_name[i],
-    value   = d,
-    append  = T
-  )
-  })
-
   # system.time({
-  # RODBC::sqlSave(
-  #   channel     = channel,
-  #   dat         = d,
-  #   tablename   = ds_extract$table_name[i],
-  #   safer       = TRUE,       # Don't keep the existing table.
-  #   rownames    = FALSE,
-  #   append      = TRUE
-  # ) %>%
-  # print()
+  # DBI::dbWriteTable(
+  #   conn    = channel_odbc,
+  #   name    = DBI::SQL(ds_extract$table_name[i]),
+  #   value   = d, #[, 1:10],
+  #   # append  = T,
+  #   overwrite = T
+  # )
   # })
 
+  system.time({
+  RODBC::sqlSave(
+    channel     = channel_rodbc,
+    dat         = d,
+    tablename   = ds_extract$table_name[i],
+    safer       = TRUE,       # Don't keep the existing table.
+    rownames    = FALSE,
+    append      = TRUE
+  ) %>%
+  print()
+  })
+
   # OuhscMunge::upload_sqls_rodbc(
   #   d               = d[1:100, ],
   #   table_name      = ds_extract$table_name[i] ,
-  #   dsn_name        = "local-nlsy-links",
+  #   dsn_name        = "local-nlsy-links-79",
   #   clear_table     = F,
   #   create_table    = T
   # )
@@ -457,6 +461,7 @@
 ## #   T2262800 <int>, T2262900 <int>, T2263000 <int>, T2263100 <int>,
 ## #   T2263200 <int>, T2263300 <int>, T2263400 <int>, T2263500 <int>,
 ## #   T2263600 <int>, T2263700 <int>, T2263800 <int>
+## [1] 1
 
## Tibble size: 4.7 Mb
@@ -512,6 +517,7 @@
 ## #   R2840300 <int>, R2840400 <int>, R2840500 <int>, R2840600 <int>,
 ## #   R2840700 <int>, R2840800 <int>, R2840900 <int>, R2841000 <int>,
 ## #   R2841100 <int>
+## [1] 1
 
## Tibble size: 5 Mb
@@ -520,7 +526,7 @@
 
## Uploading from `nlsy79-gen1/Gen1Links.csv` to `Extract.tblGen1Links`.
 
-
## # A tibble: 12,686 x 96
+
## # A tibble: 12,686 x 117
 ##    R000~ R000~ R000~ R000~ R000~ R000~ R017~ R017~ R017~ R021~ R021~ R021~
 ##    <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
 ##  1     1     1     9    58     1     1     3     3     5     3     2    20
@@ -543,7 +549,7 @@
 ## 18    18    17     3    58     2     2     3    24     1     3     1    21
 ## 19    19    19    12    57     3     3     2    28     5     3     2    21
 ## 20    20    20    11    59     2     0     3    14     5     3     2    19
-## # ... with 1.267e+04 more rows, and 84 more variables: R0329200 <int>,
+## # ... with 1.267e+04 more rows, and 105 more variables: R0329200 <int>,
 ## #   R0329210 <int>, R0406510 <int>, R0410100 <int>, R0410300 <int>,
 ## #   R0530700 <int>, R0530800 <int>, R0619010 <int>, R0809900 <int>,
 ## #   R0810000 <int>, R0898310 <int>, R1045700 <int>, R1045800 <int>,
@@ -564,10 +570,15 @@
 ## #   R7800502 <int>, R8497200 <int>, R9908000 <int>, T0000900 <int>,
 ## #   T0000901 <int>, T0000902 <int>, T0989000 <int>, T1200700 <int>,
 ## #   T1200701 <int>, T1200702 <int>, T2210800 <int>, T2260600 <int>,
-## #   T2260601 <int>, T2260602 <int>, T3108700 <int>
+## #   T2260601 <int>, T2260602 <int>, T2763400 <int>, T2763500 <int>,
+## #   T2763600 <int>, T2763700 <int>, T2763800 <int>, T2763900 <int>,
+## #   T2764000 <int>, T3108700 <int>, T3195600 <int>, T3195601 <int>,
+## #   T3195602 <int>, T3729600 <int>, T3729700 <int>, T3729800 <int>,
+## #   T3729900 <int>, T3730000 <int>, T3730100 <int>, ...
+## [1] 1
 
-
## Tibble size: 4.7 Mb
+
## Tibble size: 5.7 Mb
 
## Uploading from `nlsy79-gen1/Gen1Outcomes.csv` to `Extract.tblGen1Outcomes`.
@@ -600,6 +611,7 @@
 ## #   R1774000 <int>, T0897300 <int>, T0897400 <int>, T0897500 <int>,
 ## #   T2053800 <int>, T2053900 <int>, T2054000 <int>, T3024700 <int>,
 ## #   T3024800 <int>, T3024900 <int>
+## [1] 1
 
## Tibble size: 1.1 Mb
@@ -641,6 +653,7 @@
 ## #   BirthFatherStateMissing_2 <int>, BirthFatherStateEqual <int>,
 ## #   BirthFatherCountryMissing_1 <int>, BirthFatherCountryMissing_2 <int>,
 ## #   BirthFatherCountryEqual <int>
+## [1] 1
 
## Tibble size: 0.6 Mb
@@ -649,58 +662,59 @@
 
## Uploading from `nlsy79-gen2/Gen2FatherFromGen1.csv` to `Extract.tblGen2FatherFromGen1`.
 
-
## # A tibble: 12,686 x 939
-##    R000~ R017~ R021~ R021~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~
+
## # A tibble: 12,686 x 959
+##    R000~ R021~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~
 ##    <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
-##  1     1     5     3     2    -5    -5    -5    -5    -5    -5    -5    -5
-##  2     2     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-##  3     3     5     3     2     1    -4    -4     1    -4    -4    -4    -4
-##  4     4     5     3     2     0     1     4    -4    -4    -4    -4    -4
-##  5     5     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-##  6     6     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-##  7     7     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-##  8     8     6     3     2     1    -4    -4     1    -4    -4     1    -4
-##  9     9     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 10    10     6     3     2     1    -4    -4    -4    -4    -4    -4    -4
-## 11    11     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 12    12     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-## 13    13     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 14    14     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-## 15    15     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 16    16     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-## 17    17     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 18    18     1     3     1    -4    -4    -4    -4    -4    -4    -4    -4
-## 19    19     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-## 20    20     5     3     2    -4    -4    -4    -4    -4    -4    -4    -4
-## # ... with 1.267e+04 more rows, and 927 more variables: R1374900 <int>,
-## #   R1375400 <int>, R1375500 <int>, R1375600 <int>, R1376100 <int>,
-## #   R1376200 <int>, R1376300 <int>, R1376800 <int>, R1376900 <int>,
-## #   R1377000 <int>, R1377500 <int>, R1377600 <int>, R1377700 <int>,
-## #   R1753700 <int>, R1753800 <int>, R1753900 <int>, R1754400 <int>,
-## #   R1754500 <int>, R1754600 <int>, R1755100 <int>, R1755200 <int>,
-## #   R1755300 <int>, R1755800 <int>, R1755900 <int>, R1756000 <int>,
-## #   R1756500 <int>, R1756600 <int>, R1756700 <int>, R1757200 <int>,
-## #   R1757300 <int>, R1757400 <int>, R1757900 <int>, R1758000 <int>,
-## #   R1758100 <int>, R2095700 <int>, R2095800 <int>, R2095900 <int>,
-## #   R2096400 <int>, R2096500 <int>, R2096600 <int>, R2097100 <int>,
-## #   R2097200 <int>, R2097300 <int>, R2097800 <int>, R2097900 <int>,
-## #   R2098000 <int>, R2098500 <int>, R2098600 <int>, R2098700 <int>,
-## #   R2099200 <int>, R2099300 <int>, R2099400 <int>, R2099900 <int>,
-## #   R2100000 <int>, R2100100 <int>, R2345900 <int>, R2346200 <int>,
-## #   R2346500 <int>, R2346800 <int>, R2347100 <int>, R2347400 <int>,
-## #   R2347700 <int>, R2648000 <int>, R2648100 <int>, R2648200 <int>,
-## #   R2648700 <int>, R2648800 <int>, R2648900 <int>, R2649400 <int>,
-## #   R2649500 <int>, R2649600 <int>, R2650100 <int>, R2650200 <int>,
-## #   R2650300 <int>, R2650800 <int>, R2650900 <int>, R2651000 <int>,
-## #   R2651500 <int>, R2651600 <int>, R2651700 <int>, R2652200 <int>,
-## #   R2652300 <int>, R2652400 <int>, R2955900 <int>, R2956200 <int>,
-## #   R2956500 <int>, R2956800 <int>, R2957100 <int>, R2957400 <int>,
-## #   R2957700 <int>, R3255900 <int>, R3256000 <int>, R3256100 <int>,
-## #   R3257700 <int>, R3257800 <int>, R3257900 <int>, R3259500 <int>,
-## #   R3259600 <int>, R3259700 <int>, R3261300 <int>, ...
+##  1     1     2    -5    -5    -5    -5    -5    -5    -5    -5    -5    -5
+##  2     2     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+##  3     3     2     1    -4    -4     1    -4    -4    -4    -4    -4    -4
+##  4     4     2     0     1     4    -4    -4    -4    -4    -4    -4    -4
+##  5     5     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+##  6     6     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+##  7     7     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+##  8     8     2     1    -4    -4     1    -4    -4     1    -4    -4    -4
+##  9     9     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 10    10     2     1    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 11    11     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 12    12     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 13    13     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 14    14     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 15    15     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 16    16     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 17    17     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 18    18     1    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 19    19     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## 20    20     2    -4    -4    -4    -4    -4    -4    -4    -4    -4    -4
+## # ... with 1.267e+04 more rows, and 947 more variables: R1375500 <int>,
+## #   R1375600 <int>, R1376100 <int>, R1376200 <int>, R1376300 <int>,
+## #   R1376800 <int>, R1376900 <int>, R1377000 <int>, R1377500 <int>,
+## #   R1377600 <int>, R1377700 <int>, R1753700 <int>, R1753800 <int>,
+## #   R1753900 <int>, R1754400 <int>, R1754500 <int>, R1754600 <int>,
+## #   R1755100 <int>, R1755200 <int>, R1755300 <int>, R1755800 <int>,
+## #   R1755900 <int>, R1756000 <int>, R1756500 <int>, R1756600 <int>,
+## #   R1756700 <int>, R1757200 <int>, R1757300 <int>, R1757400 <int>,
+## #   R1757900 <int>, R1758000 <int>, R1758100 <int>, R2095700 <int>,
+## #   R2095800 <int>, R2095900 <int>, R2096400 <int>, R2096500 <int>,
+## #   R2096600 <int>, R2097100 <int>, R2097200 <int>, R2097300 <int>,
+## #   R2097800 <int>, R2097900 <int>, R2098000 <int>, R2098500 <int>,
+## #   R2098600 <int>, R2098700 <int>, R2099200 <int>, R2099300 <int>,
+## #   R2099400 <int>, R2099900 <int>, R2100000 <int>, R2100100 <int>,
+## #   R2345900 <int>, R2346200 <int>, R2346500 <int>, R2346800 <int>,
+## #   R2347100 <int>, R2347400 <int>, R2347700 <int>, R2648000 <int>,
+## #   R2648100 <int>, R2648200 <int>, R2648700 <int>, R2648800 <int>,
+## #   R2648900 <int>, R2649400 <int>, R2649500 <int>, R2649600 <int>,
+## #   R2650100 <int>, R2650200 <int>, R2650300 <int>, R2650800 <int>,
+## #   R2650900 <int>, R2651000 <int>, R2651500 <int>, R2651600 <int>,
+## #   R2651700 <int>, R2652200 <int>, R2652300 <int>, R2652400 <int>,
+## #   R2955900 <int>, R2956200 <int>, R2956500 <int>, R2956800 <int>,
+## #   R2957100 <int>, R2957400 <int>, R2957700 <int>, R3255900 <int>,
+## #   R3256000 <int>, R3256100 <int>, R3257700 <int>, R3257800 <int>,
+## #   R3257900 <int>, R3259500 <int>, R3259600 <int>, R3259700 <int>,
+## #   R3261300 <int>, R3261400 <int>, R3261500 <int>, ...
+## [1] 1
 
-
## Tibble size: 45.9 Mb
+
## Tibble size: 46.9 Mb
 
## Uploading from `nlsy79-gen2/Gen2ImplicitFather.csv` to `Extract.tblGen2ImplicitFather`.
@@ -755,6 +769,7 @@
 ## #   Y1989500 <int>, Y1990000 <int>, Y1990001 <int>, Y1992900 <int>,
 ## #   Y2197500 <int>, Y2308300 <int>, Y2308800 <int>, Y2308801 <int>,
 ## #   Y2311700 <int>, Y2531800 <int>
+## [1] 1
 
## Tibble size: 4.9 Mb
@@ -812,6 +827,7 @@
 ## #   Y1708100 <int>, Y1708200 <int>, Y1708300 <int>, Y1708400 <int>,
 ## #   Y1708500 <int>, Y1708600 <int>, Y1708700 <int>, Y1708800 <int>,
 ## #   Y1708900 <int>, Y1709000 <int>, Y1709100 <int>, ...
+## [1] 1
 
## Tibble size: 9.2 Mb
@@ -869,6 +885,7 @@
 ## #   T1486900 <int>, T1487000 <int>, T1487100 <int>, T1487200 <int>,
 ## #   T1487300 <int>, T1487400 <int>, T1487500 <int>, T1487600 <int>,
 ## #   T1487700 <int>, T1487800 <int>, T2217700 <int>, ...
+## [1] 1
 
## Tibble size: 6 Mb
@@ -910,6 +927,7 @@
 ## #   Y1385900 <int>, Y1637500 <int>, Y1637600 <int>, Y1891100 <int>,
 ## #   Y1891200 <int>, Y2207000 <int>, Y2207100 <int>, Y2544700 <int>,
 ## #   Y2544800 <int>
+## [1] 1
 
## Tibble size: 2 Mb
@@ -950,6 +968,7 @@
 ## #   C2802900 <int>, C2803000 <int>, C3111300 <int>, C3111400 <int>,
 ## #   C3111500 <int>, C3615000 <int>, C3615100 <int>, C3615200 <int>,
 ## #   C3993600 <int>, C3993700 <int>, C3993800 <int>
+## [1] 1
 
## Tibble size: 2 Mb
@@ -987,71 +1006,14 @@
 ## #   Y2623701 <int>, Y2623702 <int>, Y2623801 <int>, Y2623802 <int>,
 ## #   Y2623901 <int>, Y2623902 <int>, Y2624001 <int>, Y2624002 <int>,
 ## #   Y2624101 <int>, Y2624102 <int>
+## [1] 1
 
## Tibble size: 1.4 Mb
 
-
## Uploading from `nlsy97/97-roster.csv` to `Extract.tbl97Roster`.
-
- -
## # A tibble: 8,984 x 416
-##    R000~ R053~ R053~ R053~ R109~ R109~ R109~ R109~ R109~ R109~ R109~ R109~
-##    <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
-##  1     1     2     9  1981     6     1     4     2     3     5    -4    -4
-##  2     2     1     7  1982     3     2     1     4    -4    -4    -4    -4
-##  3     3     2     9  1983     2     1    -4    -4    -4    -4    -4    -4
-##  4     4     2     2  1981     2     1    -4    -4    -4    -4    -4    -4
-##  5     5     1    10  1982     3     1     2     4    -4    -4    -4    -4
-##  6     6     2     1  1982     3     4     1     2     5    -4    -4    -4
-##  7     7     1     4  1983     3     4     1     2     5    -4    -4    -4
-##  8     8     2     6  1981     3     4     5     2     1    -4    -4    -4
-##  9     9     1    10  1982     3     4     5     2     1    -4    -4    -4
-## 10    10     1     3  1984     3     4     5     2     1    -4    -4    -4
-## 11    11     2     6  1982     2     1     3    -4    -4    -4    -4    -4
-## 12    12     1    10  1981     4     1     3     2    -4    -4    -4    -4
-## 13    13     1    11  1984     2     1     3     4     5    -4    -4    -4
-## 14    14     1     7  1980     3     1     2     4    -4    -4    -4    -4
-## 15    15     2     1  1983     3     1     2     4    -4    -4    -4    -4
-## 16    16     1     2  1982     2     1    -4    -4    -4    -4    -4    -4
-## 17    17     2    11  1981     4     1     2     3     5     6     7     8
-## 18    18     1     2  1982     6     2     1     3     4     5    -4    -4
-## 19    19     1     4  1984     6     2     1     3     4     5    -4    -4
-## 20    20     1    12  1980     2     3     4     1    -4    -4    -4    -4
-## # ... with 8,964 more rows, and 404 more variables: R1098600 <int>,
-## #   R1098700 <int>, R1098800 <int>, R1098900 <int>, R1099000 <int>,
-## #   R1099100 <int>, R1099200 <int>, R1099300 <int>, R1101000 <int>,
-## #   R1101100 <int>, R1101200 <int>, R1101300 <int>, R1101400 <int>,
-## #   R1101500 <int>, R1101600 <int>, R1101700 <int>, R1101800 <int>,
-## #   R1101900 <int>, R1102000 <int>, R1102100 <int>, R1102200 <int>,
-## #   R1102300 <int>, R1102400 <int>, R1102500 <int>, R1102501 <int>,
-## #   R1102600 <int>, R1102700 <int>, R1102800 <int>, R1102900 <int>,
-## #   R1103000 <int>, R1103100 <int>, R1103200 <int>, R1103300 <int>,
-## #   R1103400 <int>, R1103500 <int>, R1103600 <int>, R1103700 <int>,
-## #   R1103800 <int>, R1103900 <int>, R1104000 <int>, R1104100 <int>,
-## #   R1117000 <int>, R1117100 <int>, R1117200 <int>, R1117300 <int>,
-## #   R1117400 <int>, R1117500 <int>, R1117600 <int>, R1117700 <int>,
-## #   R1117800 <int>, R1117900 <int>, R1118000 <int>, R1118100 <int>,
-## #   R1118200 <int>, R1118300 <int>, R1118400 <int>, R1118500 <int>,
-## #   R1118600 <int>, R1118700 <int>, R1118800 <int>, R1118900 <int>,
-## #   R1119000 <int>, R1119100 <int>, R1119200 <int>, R1119300 <int>,
-## #   R1119400 <int>, R1119500 <int>, R1119600 <int>, R1119700 <int>,
-## #   R1119800 <int>, R1119900 <int>, R1120000 <int>, R1120100 <int>,
-## #   R1120200 <int>, R1120300 <int>, R1120400 <int>, R1120500 <int>,
-## #   R1120600 <int>, R1120700 <int>, R1120800 <int>, R1120900 <int>,
-## #   R1121000 <int>, R1121100 <int>, R1121200 <int>, R1121300 <int>,
-## #   R1121400 <int>, R1121500 <int>, R1121600 <int>, R1121700 <int>,
-## #   R1121800 <int>, R1121900 <int>, R1122000 <int>, R1122100 <int>,
-## #   R1122200 <int>, R1122300 <int>, R1122400 <int>, R1122500 <int>,
-## #   R1122600 <int>, R1122700 <int>, R1122800 <int>, ...
-
- -
## Tibble size: 14.5 Mb
-
- -
DBI::dbDisconnect(channel); rm(channel)
-
-# RODBC::odbcClose(channel); rm(channel)
+
DBI::dbDisconnect(channel_odbc); rm(channel_odbc)
+RODBC::odbcClose(channel_rodbc); rm(channel_rodbc)
 

The R session information (including the OS info, R version and all @@ -1080,21 +1042,28 @@ ## [1] bindrcpp_0.2 magrittr_1.5 ## ## loaded via a namespace (and not attached): -## [1] Rcpp_0.12.14 rstudioapi_0.7 knitr_1.18 bindr_0.1 -## [5] odbc_1.1.3 hms_0.4.0 bit_1.1-12 testit_0.7.1 -## [9] R6_2.2.2 rlang_0.1.6 stringr_1.2.0 blob_1.1.0 -## [13] dplyr_0.7.4 tools_3.4.3 checkmate_1.8.5 utf8_1.1.2 -## [17] DBI_0.7 cli_1.0.0 bit64_0.9-7 yaml_2.1.16 -## [21] assertthat_0.2.0 tibble_1.4.1 crayon_1.3.4 purrr_0.2.4 -## [25] readr_1.1.1 tidyr_0.7.2 RODBC_1.3-15 evaluate_0.10.1 -## [29] glue_1.2.0 stringi_1.1.6 compiler_3.4.3 pillar_1.0.1 -## [33] backports_1.1.2 pkgconfig_2.0.1 +## [1] Rcpp_0.12.14 highr_0.6 plyr_1.8.4 +## [4] pillar_1.0.1 compiler_3.4.3 bindr_0.1 +## [7] tools_3.4.3 odbc_1.1.3 digest_0.6.13 +## [10] bit_1.1-12 evaluate_0.10.1 tibble_1.4.1 +## [13] checkmate_1.8.5 pkgconfig_2.0.1 rlang_0.1.6 +## [16] DBI_0.7 cli_1.0.0 rstudioapi_0.7 +## [19] yaml_2.1.16 dplyr_0.7.4 stringr_1.2.0 +## [22] knitr_1.18 hms_0.4.0 bit64_0.9-7 +## [25] rprojroot_1.3-1 glue_1.2.0 OuhscMunge_0.1.8.9005 +## [28] R6_2.2.2 rmarkdown_1.8 tidyr_0.7.2 +## [31] readr_1.1.1 purrr_0.2.4 blob_1.1.0 +## [34] scales_0.5.0.9000 backports_1.1.2 RODBC_1.3-15 +## [37] htmltools_0.3.6 rsconnect_0.8.5 assertthat_0.2.0 +## [40] testit_0.7.1 colorspace_1.3-2 utf8_1.1.2 +## [43] stringi_1.1.6 munsell_0.4.3 markdown_0.8 +## [46] crayon_1.3.4

Sys.time()
 
-
## [1] "2018-01-02 17:22:36 CST"
+
## [1] "2018-01-04 01:34:01 CST"
 
diff --git a/stitched-output/dal/import-raw.md b/stitched-output/dal/import-raw.md index b418023..daf4c51 100644 --- a/stitched-output/dal/import-raw.md +++ b/stitched-output/dal/import-raw.md @@ -29,6 +29,7 @@ requireNamespace("purrr" ) requireNamespace("dplyr" ) #Avoid attaching dplyr, b/c its function names conflict with a lot of packages (esp base, stats, and plyr). requireNamespace("testit" ) #For asserting conditions meet expected patterns. requireNamespace("RODBC" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. +requireNamespace("odbc" ) #For communicating with SQL Server over a locally-configured DSN. Uncomment if you use 'upload-to-db' chunk. ``` ```r @@ -37,24 +38,24 @@ directory_in <- "data-unshared/raw" columns_to_drop <- c("A0002600", "Y2267000") ds_extract <- tibble::tribble( - ~table_name , ~file_name, - "Extract.tblGen1Explicit" , "nlsy79-gen1/Gen1Explicit.csv", - "Extract.tblGen1Implicit" , "nlsy79-gen1/Gen1Implicit.csv", - "Extract.tblGen1Links" , "nlsy79-gen1/Gen1Links.csv", - "Extract.tblGen1Outcomes" , "nlsy79-gen1/Gen1Outcomes.csv", - "Extract.tblGen1GeocodeSanitized" , "nlsy79-gen1/Gen1GeocodeSanitized.csv", - # "Process.tblLURosterGen1" , "nlsy79-gen1/RosterGen1.csv", - # tblGen1MzDzDistinction2010 - # - "Extract.tblGen2FatherFromGen1" , "nlsy79-gen2/Gen2FatherFromGen1.csv", - "Extract.tblGen2ImplicitFather" , "nlsy79-gen2/Gen2ImplicitFather.csv", - "Extract.tblGen2Links" , "nlsy79-gen2/Gen2Links.csv", - "Extract.tblGen2LinksFromGen1" , "nlsy79-gen2/Gen2LinksFromGen1.csv", - "Extract.tblGen2OutcomesHeight" , "nlsy79-gen2/Gen2OutcomesHeight.csv", - "Extract.tblGen2OutcomesMath" , "nlsy79-gen2/Gen2OutcomesMath.csv", - "Extract.tblGen2OutcomesWeight" , "nlsy79-gen2/Gen2OutcomesWeight.csv", - - "Extract.tbl97Roster" , "nlsy97/97-roster.csv" + ~table_name , ~file_name + ,"Extract.tblGen1Explicit" , "nlsy79-gen1/Gen1Explicit.csv" + ,"Extract.tblGen1Implicit" , "nlsy79-gen1/Gen1Implicit.csv" + ,"Extract.tblGen1Links" , "nlsy79-gen1/Gen1Links.csv" + ,"Extract.tblGen1Outcomes" , "nlsy79-gen1/Gen1Outcomes.csv" + ,"Extract.tblGen1GeocodeSanitized" , "nlsy79-gen1/Gen1GeocodeSanitized.csv" + # # "Process.tblLURosterGen1" , "nlsy79-gen1/RosterGen1.csv" + # # tblGen1MzDzDistinction2010 + # # + ,"Extract.tblGen2FatherFromGen1" , "nlsy79-gen2/Gen2FatherFromGen1.csv" + ,"Extract.tblGen2ImplicitFather" , "nlsy79-gen2/Gen2ImplicitFather.csv" + ,"Extract.tblGen2Links" , "nlsy79-gen2/Gen2Links.csv" + ,"Extract.tblGen2LinksFromGen1" , "nlsy79-gen2/Gen2LinksFromGen1.csv" + ,"Extract.tblGen2OutcomesHeight" , "nlsy79-gen2/Gen2OutcomesHeight.csv" + ,"Extract.tblGen2OutcomesMath" , "nlsy79-gen2/Gen2OutcomesMath.csv" + ,"Extract.tblGen2OutcomesWeight" , "nlsy79-gen2/Gen2OutcomesWeight.csv" + + # "Extract.tbl97Roster" , "nlsy97/97-roster.csv" ) col_types_default <- readr::cols( @@ -79,7 +80,7 @@ print(ds_extract, n=20) ``` ``` -## # A tibble: 13 x 6 +## # A tibble: 12 x 6 ## table_name file_n~ path extra~ sql_se~ sql_tr~ ## ## 1 Extract.tblGen1Explicit nlsy79~ data-un~ T SELECT~ TRUNCA~ @@ -94,7 +95,6 @@ print(ds_extract, n=20) ## 10 Extract.tblGen2OutcomesHeight nlsy79~ data-un~ T SELECT~ TRUNCA~ ## 11 Extract.tblGen2OutcomesMath nlsy79~ data-un~ T SELECT~ TRUNCA~ ## 12 Extract.tblGen2OutcomesWeight nlsy79~ data-un~ T SELECT~ TRUNCA~ -## 13 Extract.tbl97Roster nlsy97~ data-un~ T SELECT~ TRUNCA~ ``` @@ -104,13 +104,13 @@ print(ds_extract, n=20) ```r -channel <- open_dsn_channel_odbc() -DBI::dbGetInfo(channel) +channel_odbc <- open_dsn_channel_odbc() +DBI::dbGetInfo(channel_odbc) ``` ``` ## $dbname -## [1] "NlsLinks" +## [1] "NlsyLinks79" ## ## $dbms.name ## [1] "Microsoft SQL Server" @@ -128,7 +128,7 @@ DBI::dbGetInfo(channel) ## [1] "" ## ## $sourcename -## [1] "local-nlsy-links" +## [1] "local-nlsy-links-79" ## ## $servername ## [1] "GIMBLE\\EXPRESS_2016" @@ -153,6 +153,8 @@ DBI::dbGetInfo(channel) ``` ```r +channel_rodbc <- open_dsn_channel_rodbc() + for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L message(glue::glue("Uploading from `{ds_extract$file_name[i]}` to `{ds_extract$table_name[i]}`.")) @@ -172,13 +174,14 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L # purrr::map_chr(d, class) print(d, n=20) - #RODBC::sqlQuery(channel, ds_extract$sql_truncate[i], errors=FALSE) - # d_peek <- RODBC::sqlQuery(channel, ds_extract$sql_select[i], errors=FALSE) + #RODBC::sqlQuery(channel_odbc, ds_extract$sql_truncate[i], errors=FALSE) + # d_peek <- RODBC::sqlQuery(channel_odbc, ds_extract$sql_select[i], errors=FALSE) - DBI::dbGetQuery(channel, ds_extract$sql_truncate[i]) + DBI::dbGetQuery(channel_odbc, ds_extract$sql_truncate[i]) - # d_peek <- DBI::dbGetQuery(channel, ds_extract$sql_select[i]) - peek <- DBI::dbListFields(channel, ds_extract$table_name[i]) + d_peek <- DBI::dbGetQuery(channel_odbc, ds_extract$sql_select[i]) + peek <- colnames(d_peek) + # peek <- DBI::dbListFields(channel_odbc, ds_extract$table_name[i]) missing_in_extract <- setdiff(peek , colnames(d)) missing_in_database <- setdiff(colnames(d), peek ) @@ -189,31 +192,32 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L # ) %>% # dplyr::filter(db != extract) - system.time({ - DBI::dbWriteTable( - conn = channel, - name = ds_extract$table_name[i], - value = d, - append = T - ) - }) - # system.time({ - # RODBC::sqlSave( - # channel = channel, - # dat = d, - # tablename = ds_extract$table_name[i], - # safer = TRUE, # Don't keep the existing table. - # rownames = FALSE, - # append = TRUE - # ) %>% - # print() + # DBI::dbWriteTable( + # conn = channel_odbc, + # name = DBI::SQL(ds_extract$table_name[i]), + # value = d, #[, 1:10], + # # append = T, + # overwrite = T + # ) # }) + system.time({ + RODBC::sqlSave( + channel = channel_rodbc, + dat = d, + tablename = ds_extract$table_name[i], + safer = TRUE, # Don't keep the existing table. + rownames = FALSE, + append = TRUE + ) %>% + print() + }) + # OuhscMunge::upload_sqls_rodbc( # d = d[1:100, ], # table_name = ds_extract$table_name[i] , - # dsn_name = "local-nlsy-links", + # dsn_name = "local-nlsy-links-79", # clear_table = F, # create_table = T # ) @@ -273,6 +277,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # T2262800 , T2262900 , T2263000 , T2263100 , ## # T2263200 , T2263300 , T2263400 , T2263500 , ## # T2263600 , T2263700 , T2263800 +## [1] 1 ``` ``` @@ -331,6 +336,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # R2840300 , R2840400 , R2840500 , R2840600 , ## # R2840700 , R2840800 , R2840900 , R2841000 , ## # R2841100 +## [1] 1 ``` ``` @@ -342,7 +348,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ``` ``` -## # A tibble: 12,686 x 96 +## # A tibble: 12,686 x 117 ## R000~ R000~ R000~ R000~ R000~ R000~ R017~ R017~ R017~ R021~ R021~ R021~ ## ## 1 1 1 9 58 1 1 3 3 5 3 2 20 @@ -365,7 +371,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## 18 18 17 3 58 2 2 3 24 1 3 1 21 ## 19 19 19 12 57 3 3 2 28 5 3 2 21 ## 20 20 20 11 59 2 0 3 14 5 3 2 19 -## # ... with 1.267e+04 more rows, and 84 more variables: R0329200 , +## # ... with 1.267e+04 more rows, and 105 more variables: R0329200 , ## # R0329210 , R0406510 , R0410100 , R0410300 , ## # R0530700 , R0530800 , R0619010 , R0809900 , ## # R0810000 , R0898310 , R1045700 , R1045800 , @@ -386,11 +392,16 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # R7800502 , R8497200 , R9908000 , T0000900 , ## # T0000901 , T0000902 , T0989000 , T1200700 , ## # T1200701 , T1200702 , T2210800 , T2260600 , -## # T2260601 , T2260602 , T3108700 +## # T2260601 , T2260602 , T2763400 , T2763500 , +## # T2763600 , T2763700 , T2763800 , T2763900 , +## # T2764000 , T3108700 , T3195600 , T3195601 , +## # T3195602 , T3729600 , T3729700 , T3729800 , +## # T3729900 , T3730000 , T3730100 , ... +## [1] 1 ``` ``` -## Tibble size: 4.7 Mb +## Tibble size: 5.7 Mb ``` ``` @@ -425,6 +436,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # R1774000 , T0897300 , T0897400 , T0897500 , ## # T2053800 , T2053900 , T2054000 , T3024700 , ## # T3024800 , T3024900 +## [1] 1 ``` ``` @@ -469,6 +481,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # BirthFatherStateMissing_2 , BirthFatherStateEqual , ## # BirthFatherCountryMissing_1 , BirthFatherCountryMissing_2 , ## # BirthFatherCountryEqual +## [1] 1 ``` ``` @@ -480,59 +493,60 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ``` ``` -## # A tibble: 12,686 x 939 -## R000~ R017~ R021~ R021~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ +## # A tibble: 12,686 x 959 +## R000~ R021~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ R137~ ## -## 1 1 5 3 2 -5 -5 -5 -5 -5 -5 -5 -5 -## 2 2 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## 3 3 5 3 2 1 -4 -4 1 -4 -4 -4 -4 -## 4 4 5 3 2 0 1 4 -4 -4 -4 -4 -4 -## 5 5 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 6 6 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 7 7 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 8 8 6 3 2 1 -4 -4 1 -4 -4 1 -4 -## 9 9 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 10 10 6 3 2 1 -4 -4 -4 -4 -4 -4 -4 -## 11 11 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 12 12 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## 13 13 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 14 14 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## 15 15 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 16 16 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## 17 17 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 18 18 1 3 1 -4 -4 -4 -4 -4 -4 -4 -4 -## 19 19 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## 20 20 5 3 2 -4 -4 -4 -4 -4 -4 -4 -4 -## # ... with 1.267e+04 more rows, and 927 more variables: R1374900 , -## # R1375400 , R1375500 , R1375600 , R1376100 , -## # R1376200 , R1376300 , R1376800 , R1376900 , -## # R1377000 , R1377500 , R1377600 , R1377700 , -## # R1753700 , R1753800 , R1753900 , R1754400 , -## # R1754500 , R1754600 , R1755100 , R1755200 , -## # R1755300 , R1755800 , R1755900 , R1756000 , -## # R1756500 , R1756600 , R1756700 , R1757200 , -## # R1757300 , R1757400 , R1757900 , R1758000 , -## # R1758100 , R2095700 , R2095800 , R2095900 , -## # R2096400 , R2096500 , R2096600 , R2097100 , -## # R2097200 , R2097300 , R2097800 , R2097900 , -## # R2098000 , R2098500 , R2098600 , R2098700 , -## # R2099200 , R2099300 , R2099400 , R2099900 , -## # R2100000 , R2100100 , R2345900 , R2346200 , -## # R2346500 , R2346800 , R2347100 , R2347400 , -## # R2347700 , R2648000 , R2648100 , R2648200 , -## # R2648700 , R2648800 , R2648900 , R2649400 , -## # R2649500 , R2649600 , R2650100 , R2650200 , -## # R2650300 , R2650800 , R2650900 , R2651000 , -## # R2651500 , R2651600 , R2651700 , R2652200 , -## # R2652300 , R2652400 , R2955900 , R2956200 , -## # R2956500 , R2956800 , R2957100 , R2957400 , -## # R2957700 , R3255900 , R3256000 , R3256100 , -## # R3257700 , R3257800 , R3257900 , R3259500 , -## # R3259600 , R3259700 , R3261300 , ... -``` - -``` -## Tibble size: 45.9 Mb +## 1 1 2 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 +## 2 2 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 3 3 2 1 -4 -4 1 -4 -4 -4 -4 -4 -4 +## 4 4 2 0 1 4 -4 -4 -4 -4 -4 -4 -4 +## 5 5 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 6 6 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 7 7 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 8 8 2 1 -4 -4 1 -4 -4 1 -4 -4 -4 +## 9 9 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 10 10 2 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 11 11 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 12 12 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 13 13 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 14 14 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 15 15 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 16 16 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 17 17 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 18 18 1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 19 19 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## 20 20 2 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 +## # ... with 1.267e+04 more rows, and 947 more variables: R1375500 , +## # R1375600 , R1376100 , R1376200 , R1376300 , +## # R1376800 , R1376900 , R1377000 , R1377500 , +## # R1377600 , R1377700 , R1753700 , R1753800 , +## # R1753900 , R1754400 , R1754500 , R1754600 , +## # R1755100 , R1755200 , R1755300 , R1755800 , +## # R1755900 , R1756000 , R1756500 , R1756600 , +## # R1756700 , R1757200 , R1757300 , R1757400 , +## # R1757900 , R1758000 , R1758100 , R2095700 , +## # R2095800 , R2095900 , R2096400 , R2096500 , +## # R2096600 , R2097100 , R2097200 , R2097300 , +## # R2097800 , R2097900 , R2098000 , R2098500 , +## # R2098600 , R2098700 , R2099200 , R2099300 , +## # R2099400 , R2099900 , R2100000 , R2100100 , +## # R2345900 , R2346200 , R2346500 , R2346800 , +## # R2347100 , R2347400 , R2347700 , R2648000 , +## # R2648100 , R2648200 , R2648700 , R2648800 , +## # R2648900 , R2649400 , R2649500 , R2649600 , +## # R2650100 , R2650200 , R2650300 , R2650800 , +## # R2650900 , R2651000 , R2651500 , R2651600 , +## # R2651700 , R2652200 , R2652300 , R2652400 , +## # R2955900 , R2956200 , R2956500 , R2956800 , +## # R2957100 , R2957400 , R2957700 , R3255900 , +## # R3256000 , R3256100 , R3257700 , R3257800 , +## # R3257900 , R3259500 , R3259600 , R3259700 , +## # R3261300 , R3261400 , R3261500 , ... +## [1] 1 +``` + +``` +## Tibble size: 46.9 Mb ``` ``` @@ -589,6 +603,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # Y1989500 , Y1990000 , Y1990001 , Y1992900 , ## # Y2197500 , Y2308300 , Y2308800 , Y2308801 , ## # Y2311700 , Y2531800 +## [1] 1 ``` ``` @@ -649,6 +664,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # Y1708100 , Y1708200 , Y1708300 , Y1708400 , ## # Y1708500 , Y1708600 , Y1708700 , Y1708800 , ## # Y1708900 , Y1709000 , Y1709100 , ... +## [1] 1 ``` ``` @@ -709,6 +725,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # T1486900 , T1487000 , T1487100 , T1487200 , ## # T1487300 , T1487400 , T1487500 , T1487600 , ## # T1487700 , T1487800 , T2217700 , ... +## [1] 1 ``` ``` @@ -753,6 +770,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # Y1385900 , Y1637500 , Y1637600 , Y1891100 , ## # Y1891200 , Y2207000 , Y2207100 , Y2544700 , ## # Y2544800 +## [1] 1 ``` ``` @@ -796,6 +814,7 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # C2802900 , C2803000 , C3111300 , C3111400 , ## # C3111500 , C3615000 , C3615100 , C3615200 , ## # C3993600 , C3993700 , C3993800 +## [1] 1 ``` ``` @@ -836,76 +855,16 @@ for( i in seq_len(nrow(ds_extract)) ) { # i <- 1L ## # Y2623701 , Y2623702 , Y2623801 , Y2623802 , ## # Y2623901 , Y2623902 , Y2624001 , Y2624002 , ## # Y2624101 , Y2624102 +## [1] 1 ``` ``` ## Tibble size: 1.4 Mb ``` -``` -## Uploading from `nlsy97/97-roster.csv` to `Extract.tbl97Roster`. -``` - -``` -## # A tibble: 8,984 x 416 -## R000~ R053~ R053~ R053~ R109~ R109~ R109~ R109~ R109~ R109~ R109~ R109~ -## -## 1 1 2 9 1981 6 1 4 2 3 5 -4 -4 -## 2 2 1 7 1982 3 2 1 4 -4 -4 -4 -4 -## 3 3 2 9 1983 2 1 -4 -4 -4 -4 -4 -4 -## 4 4 2 2 1981 2 1 -4 -4 -4 -4 -4 -4 -## 5 5 1 10 1982 3 1 2 4 -4 -4 -4 -4 -## 6 6 2 1 1982 3 4 1 2 5 -4 -4 -4 -## 7 7 1 4 1983 3 4 1 2 5 -4 -4 -4 -## 8 8 2 6 1981 3 4 5 2 1 -4 -4 -4 -## 9 9 1 10 1982 3 4 5 2 1 -4 -4 -4 -## 10 10 1 3 1984 3 4 5 2 1 -4 -4 -4 -## 11 11 2 6 1982 2 1 3 -4 -4 -4 -4 -4 -## 12 12 1 10 1981 4 1 3 2 -4 -4 -4 -4 -## 13 13 1 11 1984 2 1 3 4 5 -4 -4 -4 -## 14 14 1 7 1980 3 1 2 4 -4 -4 -4 -4 -## 15 15 2 1 1983 3 1 2 4 -4 -4 -4 -4 -## 16 16 1 2 1982 2 1 -4 -4 -4 -4 -4 -4 -## 17 17 2 11 1981 4 1 2 3 5 6 7 8 -## 18 18 1 2 1982 6 2 1 3 4 5 -4 -4 -## 19 19 1 4 1984 6 2 1 3 4 5 -4 -4 -## 20 20 1 12 1980 2 3 4 1 -4 -4 -4 -4 -## # ... with 8,964 more rows, and 404 more variables: R1098600 , -## # R1098700 , R1098800 , R1098900 , R1099000 , -## # R1099100 , R1099200 , R1099300 , R1101000 , -## # R1101100 , R1101200 , R1101300 , R1101400 , -## # R1101500 , R1101600 , R1101700 , R1101800 , -## # R1101900 , R1102000 , R1102100 , R1102200 , -## # R1102300 , R1102400 , R1102500 , R1102501 , -## # R1102600 , R1102700 , R1102800 , R1102900 , -## # R1103000 , R1103100 , R1103200 , R1103300 , -## # R1103400 , R1103500 , R1103600 , R1103700 , -## # R1103800 , R1103900 , R1104000 , R1104100 , -## # R1117000 , R1117100 , R1117200 , R1117300 , -## # R1117400 , R1117500 , R1117600 , R1117700 , -## # R1117800 , R1117900 , R1118000 , R1118100 , -## # R1118200 , R1118300 , R1118400 , R1118500 , -## # R1118600 , R1118700 , R1118800 , R1118900 , -## # R1119000 , R1119100 , R1119200 , R1119300 , -## # R1119400 , R1119500 , R1119600 , R1119700 , -## # R1119800 , R1119900 , R1120000 , R1120100 , -## # R1120200 , R1120300 , R1120400 , R1120500 , -## # R1120600 , R1120700 , R1120800 , R1120900 , -## # R1121000 , R1121100 , R1121200 , R1121300 , -## # R1121400 , R1121500 , R1121600 , R1121700 , -## # R1121800 , R1121900 , R1122000 , R1122100 , -## # R1122200 , R1122300 , R1122400 , R1122500 , -## # R1122600 , R1122700 , R1122800 , ... -``` - -``` -## Tibble size: 14.5 Mb -``` - ```r -DBI::dbDisconnect(channel); rm(channel) - -# RODBC::odbcClose(channel); rm(channel) +DBI::dbDisconnect(channel_odbc); rm(channel_odbc) +RODBC::odbcClose(channel_rodbc); rm(channel_rodbc) ``` The R session information (including the OS info, R version and all @@ -937,15 +896,22 @@ sessionInfo() ## [1] bindrcpp_0.2 magrittr_1.5 ## ## loaded via a namespace (and not attached): -## [1] Rcpp_0.12.14 rstudioapi_0.7 knitr_1.18 bindr_0.1 -## [5] odbc_1.1.3 hms_0.4.0 bit_1.1-12 testit_0.7.1 -## [9] R6_2.2.2 rlang_0.1.6 stringr_1.2.0 blob_1.1.0 -## [13] dplyr_0.7.4 tools_3.4.3 checkmate_1.8.5 utf8_1.1.2 -## [17] DBI_0.7 cli_1.0.0 bit64_0.9-7 yaml_2.1.16 -## [21] assertthat_0.2.0 tibble_1.4.1 crayon_1.3.4 purrr_0.2.4 -## [25] readr_1.1.1 tidyr_0.7.2 RODBC_1.3-15 evaluate_0.10.1 -## [29] glue_1.2.0 stringi_1.1.6 compiler_3.4.3 pillar_1.0.1 -## [33] backports_1.1.2 pkgconfig_2.0.1 +## [1] Rcpp_0.12.14 highr_0.6 plyr_1.8.4 +## [4] pillar_1.0.1 compiler_3.4.3 bindr_0.1 +## [7] tools_3.4.3 odbc_1.1.3 digest_0.6.13 +## [10] bit_1.1-12 evaluate_0.10.1 tibble_1.4.1 +## [13] checkmate_1.8.5 pkgconfig_2.0.1 rlang_0.1.6 +## [16] DBI_0.7 cli_1.0.0 rstudioapi_0.7 +## [19] yaml_2.1.16 dplyr_0.7.4 stringr_1.2.0 +## [22] knitr_1.18 hms_0.4.0 bit64_0.9-7 +## [25] rprojroot_1.3-1 glue_1.2.0 OuhscMunge_0.1.8.9005 +## [28] R6_2.2.2 rmarkdown_1.8 tidyr_0.7.2 +## [31] readr_1.1.1 purrr_0.2.4 blob_1.1.0 +## [34] scales_0.5.0.9000 backports_1.1.2 RODBC_1.3-15 +## [37] htmltools_0.3.6 rsconnect_0.8.5 assertthat_0.2.0 +## [40] testit_0.7.1 colorspace_1.3-2 utf8_1.1.2 +## [43] stringi_1.1.6 munsell_0.4.3 markdown_0.8 +## [46] crayon_1.3.4 ``` ```r @@ -953,6 +919,6 @@ Sys.time() ``` ``` -## [1] "2018-01-02 17:22:36 CST" +## [1] "2018-01-04 01:34:01 CST" ```