query: Query the application data server.

View source: R/query.R

queryR Documentation

Query the application data server.

Description

This function queries the acas databse specified in the variable applicationSettings and returns the result as a data.frame

Usage

query(qu, globalConnect = FALSE, conn = NULL, catchError = TRUE, send,
  ...)

Arguments

qu

a sql query character string

globalConnect

should the query assume a global conn variable and return one to the global namespace?

conn

a database connection to use for the query instead of opening a new connection

catchError

logical on error throw error or return list object with success = false, message = character

...

expressions fed to dbGetQuery or dbDisconnect

Value

A data frame result from the query

Examples

result <- query("select * from api_curve_params")
# conn
# Error: object 'conn' not found
result <- query("select * from api_curve_params", globalConnect=TRUE)
# conn
# <PostgreSQLConnection:(96699,1)>

# The globalConnect option:
# The first query using the global connect option will create a conn varable in the global namespace
system.time(result <- query("select * from api_curve_params", globalConnect=TRUE))
# user  system elapsed
# 0.010   0.002   0.784
# The second query will use this global variable instead of opening a new connection, which makes subsequent queryies faster
# If the connection is expired or closes, the globalConnect option will create a new connection
system.time(result <- query("select * from api_curve_params", globalConnect=TRUE))
# user  system elapsed
# 0.007   0.001   0.468

mcneilco/racas documentation built on Aug. 30, 2024, 9:27 p.m.