return_table: Query the database for a specified table, with optional...

View source: R/pmap_db_utilities.R

return_tableR Documentation

Query the database for a specified table, with optional sub-columns/where filter

Description

This function provides a way to query the database for a single table, which might be filtered using a where clause, or sub-setting by specified columns/number of rows

Usage

return_table(
  table,
  schema = "dbo",
  columns = NULL,
  max_rows = NULL,
  filter_condition = NULL,
  engine = default_engine
)

Arguments

table

database table name, string

schema

database schema name, string; default is "dbo"

columns

character vector of columns; default is NULL, which returns all columns

max_rows

maximum (integer) number of rows to return; default is NULL (all rows), currently returns TOP max_rows from table

filter_condition

string representing 'WHERE' clause of query; default is NULL (no filter).

engine

a dbConnect connection object

Value

a (lazy) dplyr::tbl / data frame object with results

Examples

return_table(table="encounters", engine = myconnection)
return_table(table="encounters", columns = c("osler_id"), max_rows=10000, engine = myconnection)
return_table(table="encounters", max_rows=10000, filter="encounter_type='Appointment'", engine = myconnection)

lmullany/pmap_utilities documentation built on July 30, 2023, 8:54 a.m.