mfdb {mfdb} | R Documentation |
MareFrame DB class
Description
Create a class representing a connection to a MareFrame DB
Usage
mfdb(schema_name,
db_params = list(),
destroy_schema = FALSE,
save_temp_tables = FALSE)
mfdb_disconnect(mdb)
Arguments
schema_name |
This can be one of:
If connecting to a SQLite/DuckDB database, db_params should remain empty (
schema_name will be used as a If connecting to a Postgres database, it can be used to store any number of case studies, by storing them in separate schemas. This parameter defines the schema to connect to, and can contain any lower case characters or underscore. |
db_params |
Extra parameters to supply to If db_params can also be supplied by environment variable, for example
if a |
destroy_schema |
Optional boolean. If true, all mfdb tables will be destroyed when
connecting. This allows you to start populating your case study from
scratch if required. The function will return NULL, you need to call
|
save_temp_tables |
Optional boolean. If true, any temporary tables will be made permanent for later inspection. |
mdb |
Database connection created by |
Value
A 'mfdb' object representing the DB connection
Examples
# Connect to a SQLite database file
mdb <- mfdb(tempfile(fileext = '.sqlite'))
mfdb_disconnect(mdb)
## Not run: # NB: Requires a PostgreSQL installation, see README
# Connect to local DB, as the "examples" case study
mdb <- mfdb('examples')
mfdb_disconnect(mdb)
# Connect to remote server, will prompt for username/password
if (interactive()) {
mdb <- mfdb('examples', db_params = list(host = "mfdb.rhi.hi.is"))
}
## End(Not run)