Import.Rd
Generic import object.
Generic import object.
This shouldn't be initialised directly - this object manages transactions and the db connection and should be extended to implement actual imports.
path
Path to directory containing import object
get_connection()
Tidy up open connections, rolling back any active transactions
Get the database connection being used by the import. Used for testing.
get_log_table()
Get the name of the log table for a particular import. This is the name of the log table configured in the dettl config
new()
Create Import object - shouldn't be called directly. Use
dettl
to create the object
Import$new(path, db_name)
reload()
Reload the objects sources to refresh source code or repair a broken Postgres connection.
extract()
Run the extract stage of the data import - does nothing for generic override in subclass if required.
transform()
Run the extract stage of the data import - does nothing for generic override in subclass if required.
pre_modify_checks()
Run checks that db can be modified, this checks that: * If require_branch set in cfg that import is for that branch * If confirm TRUE asks users to confirm action will modify db * If git is dirty, checks that user has explicitly said that is okay
load()
Run the import step ensuring tests pass before db changes are committed.
Runs the import on the DB within a transaction. Then run a set of tests on the DB and rollback the changes if any should fail.
comment
An optional comment to add to the import log table for this run.
dry_run
Whether to run in dry run mode. If TRUE then any database changes will be rolled back. Defaults to FALSE.
allow_dirty_git
If TRUE then skips check that the import is up to date with remote git repo. FALSE by default.
run_import()
For generic import this is just running the load step, expect this gets overridden in subclasses. .
Import$run_import(
comment = NULL,
dry_run = FALSE,
allow_dirty_git = FALSE,
stage = c("extract", "transorm")
)
comment
An optional comment to add to the import log table for this run.
dry_run
Whether to run in dry run mode. If TRUE then any database changes will be rolled back. Defaults to FALSE.
allow_dirty_git
If TRUE then skips check that the import is up to date with remote git repo. FALSE by default.
stage
The stage or stages of the import to be run.
format()
Custom formatter for pretty printing object summary.