class
Prostore::Connection
- Prostore::Connection
- Reference
- Object
Overview
High-level handle bundling a DB::Database pool with a chosen Adapter.
Per-connection session setup (e.g. PRAGMA foreign_keys = ON for
SQLite, ADR-0012) is installed via DB::Database#setup_connection so
every connection acquired from the pool is initialized.
Connection delegates #exec, #scalar, #query_one, #query_one?,
#query_each, and #transaction directly to the underlying pool, so
callers can use conn.exec(...) rather than conn.db.exec(...).
Defined in:
prostore/connection.crConstructors
Instance Method Summary
- #adapter : Adapter::Base
- #close : Nil
- #db : DB::Database
- #exec(query : String, *args_, args : Array | Nil = nil) : DB::ExecResult
- #query_each(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> Nil) : Nil
- #query_one(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
- #query_one?(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
- #scalar(query : String, *args_, args : Array | Nil = nil)
- #transaction(& : DB::Transaction -> T) forall T
- #url : String
-
#with_connection(&)
Acquire a single connection and yield it.
Constructor Detail
Instance Method Detail
def query_each(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> Nil) : Nil
#
def query_one(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
#
def query_one?(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
#
def with_connection(&)
#
Acquire a single connection and yield it. The runner uses this to keep all bootstrap / migration DDL on one connection so that nested operations don't deadlock the pool.