README.md

resurrectr

resurrectr is a tool to resurrect temporary databases from database dump files. Currently, only MySQL is supported. This is useful for reproducible research - rather than exporting database tables as CSV files, instead take a snapshot of the database and then spin-up a temporary database from that snapshot when necessary.

How to install

Use the devtools package to install resurrectr.

devtools::install_github("james-atkins/resurrectr.git")

Requirements

Docker must be installed to use resurrectr. Follow the links below to install it for your operating system.

Getting Started

The resurrect_mysql function creates a temporary database from the given MySQL dump file.

library(resurrectr)
db <- resurrect_mysql("~/database_backup.sql")

When db is garbage collected and/or your R script ends, the MySQL database is stopped and deleted.

Database connection settings are stored in the r db$config list. These are randomly generated. Be sure to connect to the port specified in db$config rather than 3306.

For example, to connect to the database using the RMySQL package:

library(RMySQL)

conn <- dbConnect(MySQL(), host = db$config$host, port = db$config$port,
                  dbname = db$config$dbname,
                  user = db$config$user, password = db$config$password)


james-atkins/resurrectr documentation built on Feb. 16, 2021, 12:06 a.m.