orderly_db {orderly} | R Documentation |
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, instance = NULL)
Arguments
type |
The type of connection to make ( |
root |
The path to an orderly root directory, or |
locate |
Logical, indicating if the configuration should be
searched for. If |
validate |
Logical, indicating if the database schema should
be validated on open (currently only applicable with |
instance |
Used only by |
Details
Orderly has several databases:
-
source
: All of the databases named in thedatabase
section of theorderly_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
Value
A database connection, or list of connections in the case
of source
.
Examples
# 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")