View source: R/db_connections.R
db_read | R Documentation |
Use a database connection to read from an existing SQL Server table with a SQL query.
db_read(con, query, pull_into_memory = TRUE)
con |
An odbc database connection. Can be made using
|
query |
A string, quoted, required. This sql query will be executed against the database you are connected to. |
pull_into_memory |
Logical, optional, defaults to TRUE. If FALSE,
|
Use pull_into_memory
when working with large tables.
Rather than returning the data into memory, this
function will return a reference to the specified query. It will be executed
only when needed, in a "lazy" style. Or, you can execute using the
collect()
function.
A tibble of data or reference to the table.
build_connection_string
importFrom dbplyr as.sql
## Not run: my_con <- build_connection_string(server = "HPHI-EDWDEV") con <- DBI::dbConnect(odbc::odbc(), .connection_string = my_con) d <- db_read(con, "SELECT TOP 10 * FROM [Shared].[Cost].[FacilityAccountCost]") # Get a reference and collect later ref <- db_read(con, "SELECT TOP 10 * FROM [Shared].[Cost].[FacilityAccountCost]", pull_into_memory = FALSE) d <- collect(ref) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.