Skip to content

Commit

Permalink
add schema to tables in process_foreign_data
Browse files Browse the repository at this point in the history
  • Loading branch information
andybeet committed Feb 9, 2024
1 parent 04949e5 commit b3c4a7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/get_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ get_species <- function(channel,species="all"){
query <- DBI::dbGetQuery(channel,sqlStatement)

# get column names
sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'CFSPP' and owner='CFDBS';"
sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'CFSPP' and owner='CFDBS'"
colNames <- t(DBI::dbGetQuery(channel,sqlcolName))

return (list(data=dplyr::as_tibble(query),sql=sqlStatement, colNames=colNames))
Expand Down
6 changes: 3 additions & 3 deletions R/process_foreign_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ process_foreign_data <- function(channel, nafoland, useLanded = T, useHerringMai
c('Year', 'GearCode', 'Tonnage', 'Code', 'Divcode'),
c('YEAR', 'NAFOGEAR', 'TONCL1', 'NAFOSPP', 'AREA'))

spp <- data.table::as.data.table(DBI::dbGetQuery(channel, "select NAFOSPP, NESPP3 from CFSPP"))
spp <- data.table::as.data.table(DBI::dbGetQuery(channel, "select NAFOSPP, NESPP3 from cfdbs.CFSPP"))
spp$NAFOSPP <- as.integer(spp$NAFOSPP)
spp$NESPP3 <- as.integer(spp$NESPP3)

Expand Down Expand Up @@ -118,13 +118,13 @@ process_foreign_data <- function(channel, nafoland, useLanded = T, useHerringMai

#Convert scallops to meat weight
if(useLanded) nafoland[NESPP3 == 800, SPPLIVMT := SPPLIVMT / 8.33]

#Remove herring catch - if pulling using comlandr::get_herring_data()
if(useHerringMaine) nafoland <- nafoland[NESPP3 != 168, ]

#Gearcodes

gear <- data.table::as.data.table(DBI::dbGetQuery(channel, "select NEGEAR, NAFOGEAR from Gear"))
gear <- data.table::as.data.table(DBI::dbGetQuery(channel, "select NEGEAR, NAFOGEAR from cfdbs.Gear"))
gear$NEGEAR <- as.integer(gear$NEGEAR)
gear$NAFOGEAR <- as.integer(gear$NAFOGEAR)

Expand Down

0 comments on commit b3c4a7e

Please sign in to comment.