DBI::dbConnect() establishes a connection to a database.
drv = RPostgres::Postgres() to connect to a SQL database
using the RPostgres package.
Manually disconnecting a connection is not necessary with RPostgres, but still recommended; if you delete the object containing the connection, it will be automatically disconnected during the next GC with a warning.
Postgres() # S4 method for PqDriver dbConnect( drv, dbname = NULL, host = NULL, port = NULL, password = NULL, user = NULL, service = NULL, ..., bigint = c("integer64", "integer", "numeric", "character"), check_interrupts = FALSE, timezone = "UTC", timezone_out = NULL ) # S4 method for PqConnection dbDisconnect(conn, ...)
Should be set to
to use the RPostgres package.
Database name. If
NULL, defaults to the user name.
Note that this argument can only contain the database name, it will not
be parsed as a connection string (internally,
expand_dbname is set to
false in the call to
Host and port. If
NULL, will be retrieved from
PGPORT env vars.
User name and password. If
NULL, will be
PGPASSWORD envvars, or from the
appropriate line in
Name of service to connect as. If
NULL, will be
ignored. Otherwise, connection parameters will be loaded from the pg_service.conf
file and used. See https://www.postgresql.org/docs/current/libpq-pgservice.html
for details on this file and syntax.
Other name-value pairs that describe additional connection options as described at https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
The R type that 64-bit integer types should be mapped to, default is bit64::integer64, which allows the full range of 64 bit integers.
Should user interrupts be checked during the query execution (before
first row of data is available)? Setting to
TRUE allows interruption of queries
running too long.
Sets the timezone for the connection. The default is
NULL then no timezone is set, which defaults to the server's time zone.
The time zone returned to R, defaults to
If you want to display datetime values in the local timezone,
This setting does not change the time values returned, only their display.
Connection to disconnect.