Skip to contents

This function helps with viewing database structures, by providing the right json to be ready by read_json_data_model. You can then make destructive updates to the data structure using db_write_data_model.

Usage

db_to_json_data_model(conn, file_path, schemas = NULL)

Arguments

conn

database connection object

file_path

path to save the JSON file

schemas

if NULL, all schemas will be included except information_schema, pg_catalog, postgis, admin, dev, backup & public. Otherwise, a character vector of schema names to include.

Value

a JSON file with the data model

Examples

if (FALSE) { # \dontrun{
 conn <- DBI::dbConnect(odbc::odbc(), dsn = "Legacy Landscapes", timeout = 10)
 db_to_json_data_model(conn, "data_model.json")
 m <- read_json_data_model("data_model.json")
 m <- model_relational_data(m)
 db_write_data_model(m, schema_name = NULL, crs_srid = 4326, overwrite = T, conn = conn)
 DBI::dbDisconnect(conn)
 } # }