library(tidyverse)
## ── Attaching packages ────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.0     ✔ purrr   0.3.2
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   0.8.3     ✔ 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: 610 x 12
##    is_installed num_bikes_avail… last_reported is_renting eightd_has_avai…
##           <int>            <int>         <int>      <int> <lgl>           
##  1            1                6    1606554399          1 FALSE           
##  2            1                3    1606554398          1 FALSE           
##  3            1                9    1606527318          1 FALSE           
##  4            1               10    1606523633          1 FALSE           
##  5            1                3    1606554699          1 FALSE           
##  6            1                9    1606557419          1 FALSE           
##  7            1                4    1606554099          1 FALSE           
##  8            1                6    1606526563          1 FALSE           
##  9            1                9    1606554098          1 FALSE           
## 10            1                5    1606509917          1 FALSE           
## # … with 600 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)