mysqlHasDefault: Check if default database is available.

Description Usage Examples

View source: R/default.R

Description

RMySQL examples and tests connect to a database defined by the rs-dbi group in ~/.my.cnf. This function checks if that database is available, and if not, displays an informative message.

Usage

1

Examples

1
2
3
4
5
if (mysqlHasDefault()) {
  db <- dbConnect(RMySQL::MySQL(), dbname = "test")
  dbListTables(db)
  dbDisconnect(db)
}

Example output

Loading required package: DBI
Could not initialise default MySQL database. If MySQL is running
check that you have a ~/.my.cnf file that contains a [rs-dbi] section
describing how to connect to a test database.

RMySQL documentation built on June 22, 2021, 5:08 p.m.