sql_run.Rd
utility function to run sql query
sql_run(database, query)
which database to connect to 'akfin' or 'afsc'
the sql query code
if (FALSE) {
.d = sql_read("fsh_catch.sql")
.d = sql_filter(sql_precode = "<=", 2011, sql_code = .d, flag = "-- insert year")
.d = sql_filter(x = area, sql_code = .d, flag = "-- insert region")
.d = sql_filter(sql_precode = "IN", x = c("PEL7", "PELS"),
sql_code = .d, flag = "-- insert species")
afsc = DBI::dbConnect(odbc::odbc(), "afsc", UID = "afsc_user", PWD = "afsc_pwd")
sql_run(afsc, query) %>%
vroom::vroom_write(here::here(year, 'data', 'raw', 'fsh_catch_data.csv'))
DBI::dbDisconnect(afsc)
}