qryflow {qryflow}R Documentation

Run a multi-step SQL workflow and return query results

Description

qryflow() is the main entry point to the qryflow package. It executes a SQL workflow defined in a tagged .sql script or character string and returns query results as R objects.

The SQL script can contain multiple steps tagged with ⁠@query⁠ or ⁠@exec⁠. Query results are captured and returned as a named list, where names correspond to the ⁠@query⁠ tags.

Usage

qryflow(sql, con, ..., simplify = TRUE)

Arguments

sql

A file path to a .sql workflow or a character string containing SQL code.

con

A database connection from DBI::dbConnect()

...

Additional arguments passed to qryflow_run() or qryflow_results().

simplify

Logical; if TRUE (default), a list of length 1 is simplified to the single result object.

Details

This is a wrapper around the combination of qryflow_run(), which always provides a list of results and metadata, and qryflow_results(), which filters the output of qryflow_run() to only include the results of the SQL.

Value

A named list of query results, or a single result if simplify = TRUE and only one chunk exists.

See Also

qryflow_run(), qryflow_results()

Examples

con <- example_db_connect(mtcars)

filepath <- example_sql_path("mtcars.sql")

results <- qryflow(filepath, con)

head(results$df_mtcars)

DBI::dbDisconnect(con)

[Package qryflow version 0.1.0 Index]