Skip to contents

Executes a raw SQL SELECT query and returns results as a data.table. Use this for custom queries not covered by the typed accessor functions.

The unlist parameter is useful for config lookups where you expect exactly one row and want direct field access (result$field_name).

Usage

db_art_get(qry, cn = NULL, unlist = FALSE, by_rows = FALSE)

Arguments

qry

Character. SQL SELECT query string. Must be a valid SELECT statement.

cn

Database connection. If NULL, creates a connection via artcore::dbc() and closes it on exit. Pass an existing connection to batch multiple queries efficiently.

unlist

Logical. If TRUE, returns result as a list instead of data.table. Useful for single-row lookups.

by_rows

Logical. If TRUE and unlist=TRUE, applies list conversion by rows.

Value

data.table with query results, or list if unlist=TRUE

See also