For the complete documentation index, see llms.txt. This page is also available as Markdown.

Workflow$connect_dbi

Workflow$connect_dbi() → DBI::DBIConnection

Returns a DBI connection that can be used by dbplyr and other interfaces that work with DBI. This connection is scoped to the respective workflow, avoiding the need to fully qualify tables. Tables from the workflow's datasources can be referenced by name in the same way as the workflow's own tables.

DBI::dbListTables() returns the tables in the workflow as well as the tables in its datasources, using the names that you'd use to reference them in SQL (e.g., daily_observations). To explicitly reference a table from a particular datasource (for example, if more than one datasource has a table with the same name), qualify it with the datasource's name using dbplyr::in_schema().

See redivis$connect_dbi() for the R functions that can be used within dplyr verbs.

For advanced use cases, you can also access the Redivis DBI interface at redivis::RedivisDBI. workflow$connect_dbi() is the same as: DBI::dbConnect(redivis::RedivisDBI(), workflow=workflow)

Returns:

Examples

con <- redivis$workflow("imathews.example_workflow_climate_analysis")$connect_dbi()

tbl(con, "join_lat_lon_output") |> filter(latitude > 0) |> collect()

# Prints a tibble with the filtered data

# List the tables in the workflow and its datasources
DBI::dbListTables(con)

# Reference a table from one of the workflow's datasources
tbl(con, "daily_observations") |> head(10) |> collect()

# Or, qualified with the datasource's name
tbl(con, dbplyr::in_schema("ghcn_daily_weather_data", "daily_observations")) |>
  head(10) |>
  collect()

Last updated

Was this helpful?