get_query: Get query from database

View source: R/get_query.R

get_queryR Documentation

Get query from database

Description

Execute an input SQL query and close the database connection when done. When given with no argument except query, the TCDK production database is queried.

Usage

get_query(
  query,
  driver = "ODBC Driver 17 for SQL Server",
  server = getOption("tcdkhelper.dbaddr"),
  database = "dnb_covid19",
  trusted_connection = "Yes",
  encoding = "latin1",
  timezone = Sys.timezone(),
  timezone_out = timezone
)

Arguments

query

Query to execute.

driver

Driver to use with database.

server

Name of server to query.

database

A string giving the name of the database.

trusted_connection

"Yes" / "No".

encoding

Text encoding to use. Defaults to "latin1", as this is most often used within the TCDK database.

timezone

A string giving a timezone with which to interpret datetime values returned by query. If none is given, defaults to the return value of Sys.timezone()

timezone_out

Timezone returned by query. Defaults to value of timezone

Value

The query result as a tibble.

Examples

get_query(
"SELECT TOP (10)
  MatrixPlateBC,
  DWPlateBC,
  RTimestampPM
FROM PlateFlow_Biomek

ORDER BY RTimestampPM DESC"
)

Testcenter-Danmark/tcdkhelper documentation built on March 18, 2022, 2:19 p.m.