Learn R Programming

rquery (version 0.2.0)

table_source: Table data source.

Description

Build structures (table name, column names, and quoting strategy) needed to represent data from a remote table.

Usage

table_source(table_name, columns)

Arguments

table_name

character, name of table

columns

character, column names of table

Value

a relop representation of the data

Details

Generate a query that returns contents of a table, we could try to eliminate this (replace the query with the table name), but there are features one can work with with the query in place and SQL optimizers likely make this zero-cost anyway.

Examples

Run this code
# NOT RUN {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbWriteTable(my_db,
                  'd',
                  data.frame(AUC = 0.6, R2 = 0.2),
                  overwrite = TRUE,
                  temporary = TRUE)
d <- table_source('d',
                  columns = c("AUC", "R2"))
print(d)
sql <- to_sql(d, my_db)
cat(sql)
DBI::dbGetQuery(my_db, sql)
DBI::dbDisconnect(my_db)


# }

Run the code above in your browser using DataLab