db_query: Execute an SQL query in a database

Description Usage Arguments Value See Also Examples

View source: R/db.R

Description

Execute an SQL query in a database

Usage

1
2
3
4
5
6
7
db_query(
  sql,
  db,
  ...,
  sql_formatter = getOption("dbr.sql_formatter"),
  output_format = getOption("dbr.output_format")
)

Arguments

sql

string

db

database reference by name or object

...

passed to sql_formatter

sql_formatter

function to be applied on sql potentially with ..., eg using glue for string interpolation

output_format

preferred output format that defaults to data.frame, but could be also data.table or tibble as well if the related R package is installed

Value

data.frame with query metadata

See Also

db_connect db_refresh

Examples

1
2
3
4
5
6
## Not run: 
options('dbr.db_config_path' = system.file('example_db_config.yaml', package = 'dbr'))
db_query('SELECT 42', 'sqlite')
db_query('SELECT {40 + 2}', 'sqlite')

## End(Not run)

daroczig/dbr documentation built on June 12, 2020, 2:47 p.m.