New rocker class object

Create new rocker database handling object

Option 1

db <- rocker::newDB() # New database handling object

Option 2

db <- rocker::rocker$new() # New database handling object

Terminal output

Controlling terminal output

db <- rocker::newDB(verbose = TRUE) # New database handling object
db$setupPostgreSQL()
db$unloadDriver()
db$verbose <- FALSE # Terminal output off
db$setupPostgreSQL()
db$unloadDriver()
db$verbose <- TRUE # Terminal output on (default)
db$setupPostgreSQL()
db$unloadDriver()

Structure of terminal output

Dctr | Driver load RSQLite
D                          = Driver     (D = loaded,    d = not set)
 c                         = Connection (C = opened,    c = closed)
  t                        = Transation (T = active,    t = no tranastion)
   r                       = Result     (R = available, r = no result)
       Driver load RSQLite = Message text

Optional object ID

Optionally, rocker object can be labeled with an ID. This can be helpful in case terminal output of multiple rocker objects need to be distinguished.

db1 <- rocker::newDB(id = "myDB 1") # New database handling object with ID
db2 <- rocker::newDB(id = "myDB 2") # New database handling object with ID
db1$setupPostgreSQL()
db2$setupMariaDB()
db1$unloadDriver()
db2$unloadDriver()
db1$id <- NULL # Remove ID
db1$setupSQLite()
db1$unloadDriver()
db1$id <- "newID 1" # Add new ID
db1$setupSQLite()
db1$unloadDriver()

Object properties

Object properties are stored in the info field and can be displayed by print function.

db <- rocker::newDB() # New database handling object
db$setupPostgreSQL()
db$info
db
db$print()
print(db)
db$unloadDriver()

Connection validation -- Is the earlier opened database connection still open?

db <- rocker::newDB() # New database handling object
db$setupSQLite()
db$print()

During connection setup, a validateQuery is looked up automatically.

db$connect()
db$print()

Discovered validateQuery

db$validateQuery

Validate connection

db$validateCon()

If required, validateQuery can be defined manually.

db$validateQuery <- "SELECT 2"
db$validateCon()
db$print()

Clean up

db$disconnect()
db$validateCon()
db$unloadDriver()


Try the rocker package in your browser

Any scripts or data that you put into this service are public.

rocker documentation built on Aug. 21, 2022, 1:06 a.m.