runQuery: Run queries via a GCAM database connection and recieve...

View source: R/querymi.R

runQueryR Documentation

Run queries via a GCAM database connection and recieve results as data.frame

Description

To run a query users need to supply a database connection, the query to run, the scenarios to query, and regions to query.

Usage

runQuery(dbConn, query, scenarios = NULL, regions = NULL, warn.empty = TRUE)

## S3 method for class 'localDBConn'
runQuery(dbConn, query, scenarios = NULL, regions = NULL, warn.empty = TRUE)

## S3 method for class 'remoteDBConn'
runQuery(dbConn, query, scenarios = NULL, regions = NULL, warn.empty = TRUE)

Arguments

dbConn

The connection to a database which will handle running the query.

query

A Model Interface query to run. This is typically provided as the XML typically found in the Main_queries.xml but could also be given for instance as a query string that will result in XML such as: doc('../output/queries/Main_queries.xml')//*[@title='Cogeneration by sector']

scenarios

A character vector of scenarios to query. Passing NULL in this argument will query the last scenario in the database. Each value can either be the scenario name or the scenario name and date seperated by a space. Note the date is specified exactly as in appears in the database.

regions

A character vector of regions to query. NULL will run the query over all regions.

warn.empty

Flag: Issue a warning if a query is empty.

Value

A data.frame with the results.

Methods (by class)

  • localDBConn: Run a query on a local GCAM database

  • remoteDBConn: Run query specialization for remote databases


JGCRI/rgcam documentation built on July 2, 2022, 10:20 a.m.