connection-utils: Database connection utilities

Description Usage Arguments Details Value Author(s) Examples

Description

Conection reporting and defaults

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

Arguments

opts

a libpq connection string

all

if false return only defaults with settings

what

the fields to return or all if NULL

hide_password

if true, do not reveal password used

...

a named list of arguments giving new defaults

password

the password

Details

ping will ignore any keywords not directly related to the database host (e.g., username, dbname) as it does not connect; it only detect the server port is responding.

get_conn_defaults returns a data frame containing all of the possible connection string keywords, the names of environment variables used to override the defaults, the compiled in default value and the current value of the keyword.

get_conn_info returns a list containing information about the current connection. For readability, it will print as though it is a matrix. If you want to see it as a list, try unclass(get_conn_info()).

If length(what) == 1 then get_conn_info returns a scalar

set_conn_defaults sets the connection defaults by calling Sys.setenv and setting the environment variable associated with the connection keywords returned by get_conn_defaults(all = TRUE). These settings will only last as long as the current shell session and will reset after a new login.

set_default_password will query for a password (if not supplied) and set the PGPASSWORD environment variable accordingly. This can be used with psql and copy_to.

reset_conn_defaults unsets all environment variables returned by get_conn_defaults(all = TRUE).

Value

ping returns one of the following:

PQPING_OK Server reachable
PQPING_REJECT Server reachable but not accepting connections
PQPING_NO_RESPONSE Server unreachable
PQPING_NO_ATTEMPT Connection string is nonsense

get_conn_error: an error string

get_conn_defaults: a data frame with defaults listed

get_conn_info: a list of values

Author(s)

Timothy H. Keitt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
ping("connect_timeout = 3, host = www.keittlab.org")
connect()
get_conn_defaults()
set_conn_defaults(dbname = "test")
get_conn_defaults()
reset_conn_defaults()
get_conn_defaults()
get_conn_defaults(all = TRUE)
get_conn_info()
get_conn_error()
disconnect()
## End(Not run)

thk686/rpg documentation built on Sept. 5, 2019, 11:13 p.m.