postgresHasDefault function

Check if default database is available.

Check if default database is available.

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.

postgresHasDefault(...) postgresDefault(...)

Arguments

  • ...: Additional arguments passed on to DBI::dbConnect()

Examples

if (postgresHasDefault()) { db <- postgresDefault() print(dbListTables(db)) dbDisconnect(db) } else { message("No database connection.") }
  • Maintainer: Kirill Müller
  • License: MIT + file LICENSE
  • Last published: 2025-02-25