class
CQL::Postgres::Connection
- CQL::Postgres::Connection
- DB::Connection
- Reference
- Object
Overview
A crystal-db connection over a wire Session: what Executor#exec_query
yields, so every CQL statement type runs on it unchanged.
Defined in:
postgres/connection.crConstant Summary
-
DRIVER_NAME =
"postgres"
Constructors
- .new(session : CQL::Postgres::Session, options : DB::Connection::Options = ::DB::Connection::Options.new(prepared_statements_cache: false))
-
.open(config : Config, options : DB::Connection::Options = ::DB::Connection::Options.new(prepared_statements_cache: false)) : Connection
crystal-db's own per-connection statement-wrapper cache is off: the session already keeps a bounded cache of prepared statements.
Instance Method Summary
-
#build_prepared_statement(query) : DB::Statement
:nodoc:
-
#build_unprepared_statement(query) : DB::Statement
:nodoc:
- #cancel : Nil
-
#clear_handlers : Nil
Per-borrower state (notice and notification handlers) does not outlive a checkout.
-
#closed? : Bool
A connection whose session was dropped (after a network error, a protocol error or a timeout) is closed for good, even if nobody called
close. - #copy_in(sql : String, & : CopyIn -> ) : Int64
- #copy_in_binary(sql : String, types : Array(UInt32), & : BinaryCopy::Writer -> ) : Int64
- #copy_out(sql : String, & : Bytes -> ) : Int64
- #copy_out_binary(sql : String, types : Array(UInt32), &on_row : Array(Types::Value) -> ) : Int64
-
#driver_name : String
crystal-db 0.15 requires it: the name the driver is registered with.
-
#exec_all(sql : String) : Nil
Runs a script of several statements; no rows come back.
- #in_transaction? : Bool
-
#inspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
- #on_notice(&handler : Hash(Char, String) -> ) : Nil
- #on_notification(&handler : Notification -> ) : Nil
- #ping(timeout : Time::Span = CQL::Postgres::Session::PING_TIMEOUT) : Bool
-
#pipeline(statements : Array(Tuple(String, Array(Types::Param)))) : Array(Result | ServerError)
Several statements, one network round trip.
- #session : CQL::Postgres::Session
- #stream(sql : String, args : Enumerable, fetch_size : Int32 = 1000, timeout : Time::Span | Nil = nil, & : DB::ResultSet -> T) : T forall T
-
#stream(sql : String, *args, fetch_size : Int32 = 1000, timeout : Time::Span | Nil = nil, & : DB::ResultSet -> T) : T forall T
Runs a query and yields a result set that reads rows from the server fetch_size at a time, so a large result is never held whole.
Constructor Detail
crystal-db's own per-connection statement-wrapper cache is off: the session already keeps a bounded cache of prepared statements.
Instance Method Detail
:nodoc:
:nodoc:
Per-borrower state (notice and notification handlers) does not outlive a checkout.
A connection whose session was dropped (after a network error, a protocol
error or a timeout) is closed for good, even if nobody called close.
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Several statements, one network round trip. See Session#pipeline.
Runs a query and yields a result set that reads rows from the server
fetch_size at a time, so a large result is never held whole. The
connection is busy until the block returns; stopping early is fine. See
Session#stream for the details, including the timeout.
engine = CQL::Postgres::AsyncEngine.connect(ENV["DATABASE_URL"])
engine.with_connection do |connection|
connection.stream("SELECT id, name FROM users WHERE age > $1", 18, fetch_size: 500) do |rows|
rows.each { puts "#{rows.read(Int64)} #{rows.read(String)}" }
end
end