Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

postgresHasDefault

Check if default database is available.


Description

RPostgres examples and tests connect to a default database via dbConnect(Postgres()). This function checks if that database is available, and if not, displays an informative message.

postgresDefault() works similarly but returns a connection on success and throws a testthat skip condition on failure, making it suitable for use in tests.

Usage

postgresHasDefault(...)

postgresDefault(...)

Arguments

...

Additional arguments passed on to dbConnect()

Examples

if (postgresHasDefault()) {
  db <- postgresDefault()
  dbListTables(db)
  dbDisconnect(db)
}

RPostgres

'Rcpp' Interface to 'PostgreSQL'

v1.3.2
GPL-3
Authors
Hadley Wickham [aut], Jeroen Ooms [aut], Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>), RStudio [cph], R Consortium [fnd], Tomoaki Nishiyama [ctb] (Code for encoding vectors into strings derived from RPostgreSQL)
Initial release
2021-04-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.