orderly (version 1.0.4)

orderly_db: Connect to orderly databases

Description

Connect to the orderly databases. These should be treated as as read-only.

Usage

orderly_db(type, root = NULL, locate = TRUE, validate = TRUE)

Arguments

type

The type of connection to make (source, destination, csv or rds).

root

The path to an orderly root directory, or NULL (the default) to search for one from the current working directory if locate is TRUE.

locate

Logical, indicating if the configuration should be searched for. If TRUE and config is not given, then orderly looks in the working directory and up through its parents until it finds an orderly_config.yml file.

validate

Logical, indicating if the database schema should be validated on open (currently only applicable with type = "destination"). This is primarily intended for internal use.

Value

A database connection, or list of connections in the case of source.

Details

Orderly has several databases:

source

All of the databases named in the database section of the orderly_config.yml

destination

The orderly index database (typically a SQLite database stored at the orderly root)

csv

The cache of database query results, in csv format

rds

The cache of database query results, in rds format

Examples

Run this code
# NOT RUN {
# Create an orderly that has a single commited report:
path <- orderly::orderly_example("minimal")
id <- orderly::orderly_run("example", root = path)
orderly::orderly_commit(id, root = path)

# The source database holds the data that might be accessible via
# the 'data' entry in orderly.yml:
db <- orderly::orderly_db("source", root = path)
# This is a list, with one connection per database listed in the
# orderly_config.yml (an empty list if none are specified):
db
DBI::dbListTables(db$source)
head(DBI::dbReadTable(db$source, "data"))
DBI::dbDisconnect(db$source)

# The destination database holds information about the archived
# reports:
db <- orderly::orderly_db("destination", root = path)
DBI::dbListTables(db)

# These tables are documented online:
# https://vimc.github.io/orderly/schema
DBI::dbReadTable(db, "report_version")
# }

Run the code above in your browser using DataLab