DRDataRaft/ docs
GitHub ↗

dr_source_database()

Supply exactly one of table and query. The connection may be an open DBI connection or a zero-argument factory. Only factory-created connections are closed by dataraft. SQL is passed to DBI unchanged; use params for values. Nothing is queried during construction or structural preflight.

Usage

dr_source_database(
  connection,
  table = NULL,
  query = NULL,
  params = NULL,
  lazy = !is.function(connection) && is.null(params)
)

Arguments

connection
DBI connection or function opening one.


table
Table name or DBI::Id().


query
A single SQL query string.


params
Parameters passed to DBI::dbGetQuery(). Parameterized queries are materialized, because DBI binding is not a lazy query.


lazy
Keep a caller-owned DBI table lazy. Defaults to TRUE for open connections without parameters and FALSE for factories. Factories are closed before returning and cannot provide lazy output.

Value

A source specification accepted by dataraft.core::dr_add_source().

Examples

\dontshow{if (requireNamespace("duckdb", quietly = TRUE)) withAutoprint(\{ # examplesIf}
con <- DBI::dbConnect(duckdb::duckdb(), bigint = "integer64")
DBI::dbWriteTable(con, "orders", data.frame(id = 1:2))
dataraft.core::dr_read_source(dr_source_database(con, table = "orders"))
DBI::dbDisconnect(con, shutdown = TRUE)
\dontshow{\}) # examplesIf}
Documentation source snapshot · View source at 2f9432d ↗
Code examples are documented source examples; they are not executed in this website build.

Search documentation

Search functions, packages and guides.