Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate in four steps how to read databases #77

Closed
avallecam opened this issue Jun 17, 2024 · 0 comments · Fixed by #143
Closed

separate in four steps how to read databases #77

avallecam opened this issue Jun 17, 2024 · 0 comments · Fixed by #143
Assignees
Labels
clean-validation set of issues about the clean-validation episode priority upcoming-training To prioritize

Comments

@avallecam
Copy link
Member

after some changes, I think we can separate the steps here into four subtitles. This will increase the possibility to show extra info within each step.

  1. connect with the database

show in a callout that this may look in real-life

# in real-life
db_con <- DBI::dbConnect(
  RSQLite::SQLite(), 
  host = "database.epiversetrace.com",
  user = "juanito",
  password = epiversetrace::askForPassword("Database password")
)
  1. write a local data frame as a table in the database

...

  1. read data from table
library(dbplyr)

# Take a reference of one table from the database
mydb <- tbl(src = db_con, "cases")

# Show the SQL queries translated
mydb %>% 
  dplyr::filter(confirm > 50) %>% 
  dplyr::arrange(desc(confirm)) %>% 
  dplyr::show_query()

# Pull all data down to a local tibble
mydb %>% 
  dplyr::filter(confirm > 50) %>% 
  dplyr::arrange(desc(confirm)) %>% 
  dplyr::collect()
  1. close database connection

...

Originally posted by @avallecam in #70 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean-validation set of issues about the clean-validation episode priority upcoming-training To prioritize
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant