class DB::Database

Overview

Acts as an entry point for database access. Connections are managed by a pool. The connection pool can be configured from URI parameters:

It should be created from DB module. See DB#open.

Refer to QueryMethods for documentation about querying the database.

Included Modules

Defined in:

db/database.cr

Instance Method Summary

Instance methods inherited from module DB::QueryMethods

exec(query, *args) exec, query(query, *args)
query(query, *args, &block)
query
, query_all(query, *args, &block : ResultSet -> U) : Array(U)
query_all(query, *args, as types : Tuple)
query_all(query, *args, as type : Class)
query_all
, query_one(query, *args, &block : ResultSet -> U) : U
query_one(query, *args, as types : Tuple)
query_one(query, *args, as type : Class)
query_one
, query_one?(query, *args, &block : ResultSet -> U) : U?
query_one?(query, *args, as types : Tuple)
query_one?(query, *args, as type : Class)
query_one?
, scalar(query, *args) scalar

Instance Method Detail

def close #

Closes all connection to the database.


[View source]
def setup_connection(&proc : Connection -> Nil) #

[View source]
def uri : URI #

Returns the uri with the connection settings to the database


[View source]
def using_connection(&block) #

yields a connection from the pool the connection is returned to the pool after when the block ends


[View source]