Use case: unit testing code that manipulates data frames obtained by querying a Postgres database. Auto-generate functions for creating in memory data frames that mirror the structure of the database, for easy mocking of the tables.
Note that for now this only supports Postgres databases with the following types: “integer”, “smallint”, “boolean”, “numeric”, “real”, “date”, “timestamp without time zone”, “timestamp with time zone”
./scripts/start_test_db.sh
. Then you can use the following connection: con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = "northwind",
host = "localhost",
user = "northwind",
password = "northwind")
db <- fakerbase::fb_generate(con, schema_name = "public")
region <- db$region(region_id = 123L, region_description = "Central America")
str(region)
'data.frame': 1 obs. of 2 variables:
$ region_id : int 123
$ region_description: chr "Central America"
db <- fakerbase::fb_load("northwind", schema_name = "public")