get_connection {SCDB} | R Documentation |
Opens connection to the database
Description
This is a convenience wrapper for DBI::dbConnect() for different database backends.
Connects to the specified dbname of host:port using user and password from given arguments (if applicable). Certain drivers may use credentials stored in a file, such as ~/.pgpass (PostgreSQL).
Usage
get_connection(drv, ...)
## S3 method for class 'SQLiteDriver'
get_connection(
drv,
dbname = ":memory:",
...,
bigint = c("integer", "bigint64", "numeric", "character")
)
## S3 method for class 'PqDriver'
get_connection(
drv,
dbname = NULL,
host = NULL,
port = NULL,
password = NULL,
user = NULL,
...,
bigint = c("integer", "bigint64", "numeric", "character"),
check_interrupts = TRUE,
timezone = Sys.timezone(),
timezone_out = Sys.timezone()
)
## S3 method for class 'OdbcDriver'
get_connection(
drv,
dsn = NULL,
...,
bigint = c("integer", "bigint64", "numeric", "character"),
timezone = Sys.timezone(),
timezone_out = Sys.timezone()
)
## S3 method for class 'duckdb_driver'
get_connection(
drv,
dbdir = ":memory:",
...,
bigint = c("numeric", "character"),
timezone_out = Sys.timezone()
)
## Default S3 method:
get_connection(drv, ...)
Arguments
drv |
( |
... |
Additional parameters sent to DBI::dbConnect(). |
dbname |
( |
bigint |
( |
host |
( |
port |
( |
password |
( |
user |
( |
check_interrupts |
( |
timezone |
( |
timezone_out |
( |
dsn |
( |
dbdir |
( |
Value
An object that inherits from DBIConnection
driver specified in drv
.
See Also
Examples
conn <- get_connection(drv = RSQLite::SQLite(), dbname = ":memory:")
DBI::dbIsValid(conn) # TRUE
close_connection(conn)
DBI::dbIsValid(conn) # FALSE