Learn R Programming

dm (version 0.1.2)

dm_from_src: Load a dm from a remote data source

Description

dm_from_src() creates a dm from some or all tables in a src (a database or an environment) or which are accessible via a DBI-Connection. For Postgres and SQL Server databases, primary and foreign keys are imported from the database.

Usage

dm_from_src(src = NULL, table_names = NULL, learn_keys = NULL, ...)

Arguments

src

A dplyr table source object or a DBI::DBIConnection object is accepted.

table_names

A character vector of the names of the tables to include.

learn_keys

experimental

Set to TRUE to query the definition of primary and foreign keys from the database. Currently works only for Postgres and SQL Server databases. The default attempts to query and issues an informative message.

...

experimental

Additional parameters for the schema learning query. Currently supports schema (default: "public") and table_type (default: "BASE TABLE") for Postgres databases.

Value

A dm object.

Examples

Run this code
# NOT RUN {
dm_from_src_demo <- function() {
  if (!rlang::is_installed("DBI")) {
    message("Install the DBI package to run this example.")
  }

  con <- DBI::dbConnect(
    RMariaDB::MariaDB(),
    username = "guest",
    password = "relational",
    dbname = "Financial_ijs",
    host = "relational.fit.cvut.cz"
  )
  on.exit(DBI::dbDisconnect(con))

  dm_from_src(con)
}
# }
# NOT RUN {
dm_from_src_demo()
# }

Run the code above in your browser using DataLab