library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✔ ggplot2 3.2.1     ✔ purrr   0.3.3
## ✔ tibble  2.1.3     ✔ dplyr   0.8.4
## ✔ tidyr   1.0.2     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(odbc)
library(bikeHelpR)

con <- dbConnect(odbc::odbc(), "Content DB", timeout = 10)

Download updated data

feeds <- feeds_urls()
# Get station status Data
dat <- feeds %>% 
   filter(name == "station_status") %>% 
   pull(url) %>% 
   get_data()


(df <- dat %>%
      magrittr::extract2("data") %>%
      mutate(time = dat$last_updated) %>%
      select(is_installed, num_bikes_available, last_reported, 
             is_renting, eightd_has_available_keys, num_docks_available, 
             num_docks_disabled, is_returning, station_id, 
             num_ebikes_available, num_bikes_disabled, time))
## # A tibble: 652 x 12
##    is_installed num_bikes_avail… last_reported is_renting eightd_has_avai…
##           <int>            <int>         <int>      <int> <lgl>           
##  1            1                7    1632786619          1 FALSE           
##  2            1               15    1632794809          1 FALSE           
##  3            1                0    1632790936          1 FALSE           
##  4            1               11    1632780834          1 FALSE           
##  5            1                1    1632799469          1 FALSE           
##  6            1                4    1632794567          1 FALSE           
##  7            1                1    1632801850          1 FALSE           
##  8            1                0    1632794316          1 FALSE           
##  9            1                4    1632799034          1 FALSE           
## 10            1                0    1632734274          1 FALSE           
## # … with 642 more rows, and 7 more variables: num_docks_available <int>,
## #   num_docks_disabled <int>, is_returning <int>, station_id <chr>,
## #   num_ebikes_available <int>, num_bikes_disabled <int>, time <dttm>
dbWriteTable(con, "bike_raw_data", df, append = TRUE)
dbDisconnect(con)