Learn R Programming

taskqueue (version 0.2.0)

is_db_connect: Test Database Connection

Description

Checks whether a connection to the PostgreSQL database can be established with the current configuration.

Usage

is_db_connect()

Arguments

Value

Logical. TRUE if the database can be connected successfully,

FALSE otherwise.

Details

This function attempts to create a database connection using the credentials in environment variables or taskqueue_options(). It returns FALSE if the connection fails for any reason (wrong credentials, network issues, PostgreSQL not running, etc.).

Useful for testing database configuration before running workers or adding tasks.

See Also

db_connect, taskqueue_options

Examples

Run this code
if (FALSE) {
# Not run:
# Test connection
if (is_db_connect()) {
  message("Database is accessible")
  db_init()
} else {
  stop("Cannot connect to database. Check .Renviron settings.")
}
}

Run the code above in your browser using DataLab