The Engine class is a core component of the oRm framework, responsible for managing
database connections and providing methods for interacting with the database.
It supports both direct connections and connection pooling, offering flexibility
in how database resources are managed.
Key features:
Manages database connections (single or pooled)
Provides methods for executing SQL queries and commands
Allows creation of TableModel objects for ORM operations
Supports persistent connections for improved performance
Methods
Method new()
Usage
Engine$new(..., conn_args = list(), use_pool = FALSE, persist = FALSE)
Arguments
...
args to be passed to DBI::dbConnect
conn_args
args to be passed to DBI::dbConnect
use_pool
whether or not to make use of the pool package for connections to this engine
persist
whether to keep the connection open after operations (default: FALSE)
Get a connection to the database
Method get_connection()
Returns
A DBIConnection object or a pool object
Close the database connection or pool
list tables in the database connection
Execute a SQL query and return the result as a data.frame
Method get_query()
Returns
A data.frame
Execute a SQL query and return the number of rows affected
Create a new TableModel object for the specified table
Method model()
Usage
Engine$model(tablename, ..., .data = list())
Arguments
tablename
Name of the table
...
Additional arguments passed to the TableModel constructor
.data
a named list of the arguments for the TableModel constructor
Method clone()
The objects of this class are cloneable with this method.
Usage
Engine$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.