dm_from_con()
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.
Arguments
- con
A
DBI::DBIConnection
or aPool
object.- table_names
A character vector of the names of the tables to include.
- learn_keys
-
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. - .names
-
A glue specification that describes how to name the tables within the output, currently only for MSSQL, Postgres and MySQL/MariaDB. This can use
{.table}
to stand for the table name, and{.schema}
to stand for the name of the schema which the table lives within. The default (NULL
) is equivalent to"{.table}"
when a single schema is specified inschema
, and"{.schema}.{.table}"
for the case where multiple schemas are given, and may change in future versions. - ...
-
Additional parameters for the schema learning query.
schema
: supported for MSSQL (default:"dbo"
), Postgres (default:"public"
), and MariaDB/MySQL (default: current database). Learn the tables in a specific schema (or database for MariaDB/MySQL).dbname
: supported for MSSQL. Access different databases on the connected MSSQL-server; default: active database.table_type
: supported for Postgres (default:"BASE TABLE"
). Specify the table type. Options are:"BASE TABLE"
for a persistent table (normal table type)"VIEW"
for a view"FOREIGN TABLE"
for a foreign table"LOCAL TEMPORARY"
for a temporary table
Examples
con <- dm_get_con(dm_financial())
# Avoid DBI::dbDisconnect() here, because we don't own the connection