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.

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 lifecycle

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 lifecycle

Additional parameters for the schema learning query.

  • schema: supported for MSSQL (default: "dbo") and Postgres (default: "public"). Learn the tables in a specific schema.

  • dbname: supported for MSSQL. Access different databases on the connected MSSQL-server; default: database addressed by src.

  • table_type: supported for Postgres (default: "BASE TABLE"). Specify the table type. Options are:

    1. "BASE TABLE" for a persistent table (normal table type)

    2. "VIEW" for a view

    3. "FOREIGN TABLE" for a foreign table

    4. "LOCAL TEMPORARY" for a temporary table

Value

A dm object.

Examples

con <- DBI::dbConnect( RMariaDB::MariaDB(), username = "guest", password = "relational", dbname = "Financial_ijs", host = "relational.fit.cvut.cz" ) dm_from_src(con)
#> Keys could not be queried, use `learn_keys = FALSE` to mute this message.
#> ── Table source ──────────────────────────────────────────────────────────────── #> src: mysql [guest@relational.fit.cvut.cz:NA/Financial_ijs] #> ── Metadata ──────────────────────────────────────────────────────────────────── #> Tables: `accounts`, `cards`, `clients`, `disps`, `districts`, … (9 total) #> Columns: 57 #> Primary keys: 0 #> Foreign keys: 0
DBI::dbDisconnect(con)