db_select_data: Basic SELECT statement wrapper returning results in a tibble

Description Usage Arguments Value Examples

View source: R/db_get.R

Description

Wrapper around DBI and formatting functions to execute a SELECT statement and return the results in a tibble.

Usage

1
db_select_data(con, select_statement)

Arguments

con

A DBIConnection object, as returned by DBI::dbConnect().

select_statement

a character string representing a SQL SELECT statement.

Value

a tibble with the results.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
con <- RSQLite::dbConnect(RSQLite::SQLite(), ":memory:")
p <- tibble::tibble(SUBJECT_ID = c(10006, 10011))
a <- tibble::tibble(SUBJECT_ID = c(10006, 10011))
RSQLite::dbWriteTable(con, "PATIENTS", p)
RSQLite::dbWriteTable(con, "ADMISSIONS", a)

patients <- db_select_data(con, "SELECT * FROM PATIENTS")
admissions <- db_select_data(con, "SELECT * FROM ADMISSIONS WHERE SUBJECT_ID = 10006")

RSQLite::dbDisconnect(con)

hdshea/MIMIC3db documentation built on Dec. 20, 2021, 3:44 p.m.