class

Prostore::Connection

Inherits Reference < Object

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(...).

Constructors

new(db : DB::Database, adapter : Adapter::Base, url : String)
Source
open(url : String) : Connection
Source

Instance methods

adapter
Source
close
Source
exec(query : String, *args_, args : Array | Nil = nil) : DB::ExecResult
Source
query_each(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> Nil) : Nil
Source
query_one(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
Source
query_one?(query : String, *args_, args : Array | Nil = nil, & : DB::ResultSet -> T) forall T
Source
scalar(query : String, *args_, args : Array | Nil = nil)
Source
transaction
Source
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.

Source