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
Public fields
conn_args
A list of arguments for establishing a connection
conn
Active database connection or pool
use_pool
Whether to use connection pooling
persist
Whether to keep connections open between operations
dialect
Database dialect in use
schema
Default schema applied to tables
Methods
Method new()
Create an Engine object
Arguments
...
Additional arguments to be passed to DBI::dbConnect
conn_args
A list of arguments to be passed to DBI::dbConnect
.schema
Character. The default schema to apply to child TableModel objects
use_pool
Logical. Whether or not to make use of the pool package for connections to this engine
persist
Logical. Whether to keep the connection open after operations (default: FALSE) Get a connection to the database
Reapplies the configured schema on every connection retrieval to ensure consistency after reconnects.
Method set_schema()
Set the default schema for the engine and active connection
Method model()
Create a new TableModel object for the specified table
Usage
Engine$model(tablename, ..., .data = list(), .schema = NULL)
Method qualify()
Qualify a table name with a schema
Method print()
Print a concise summary of the engine.