-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.R
More file actions
34 lines (27 loc) · 719 Bytes
/
loop.R
File metadata and controls
34 lines (27 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(jsonlite)
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
library(purrr, warn.conflicts = FALSE)
library(DBI)
library(future)
plan(multicore)
# credentials
dw <- config::get("datawarehouse")
# connect to db
con <- DBI::dbConnect(
odbc::odbc(),
Driver = dw$driver,
Server = dw$server,
Database = dw$database,
UID = dw$uid,
PWD = dw$pwd,
Port = dw$port
)
# source functions
source("R/utils.R")
# drop all tables before rewriting new tables # <--- Uncomment the line below, commented out to avoid deleting all tables by accident
drop_all_tables(con)
# fetch links json file
openfda_device_links <- fetch_adverse_event_links()
# refresh the database
refresh_db(rev(openfda_device_links))