diff --git a/api/0.4.0/DB.html b/api/0.4.0/DB.html
new file mode 100644
index 0000000..d7c7d7e
--- /dev/null
+++ b/api/0.4.0/DB.html
@@ -0,0 +1,683 @@
+
+
+
+
+
+
+
+ DB - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB
+
+
+
+
+
+
+
+
Overview
+
+
The DB module is a unified interface to database access.
+Database dialects is supported by custom database driver shards.
+Check crystal-lang/crystal-sqlite3 for example.
+
+
Drivers implementors check Driver
class.
+
+
DB manage a connection pool. The connection pool can be configured by URI
query. See Database
.
+
+
Usage
+
+
Assuming crystal-sqlite3
is included a sqlite3 database can be opened with #open
.
+
+
db = DB .open "sqlite3:./path/to/db/file.db"
+db.close
+
+
If a block is given to #open
the database is closed automatically
+
+
DB .open "sqlite3:./file.db" do | db|
+ # work with db
+end # db is closed
+
+
In the code above db
is a Database
. Methods available for querying it are described in QueryMethods
.
+
+
Three kind of statements can be performed:
+
+
Database#exec
waits no response from the database.Database#scalar
reads a single value of the response.Database#query
returns a ResultSet that allows iteration over the rows in the response and column information.
+
+
All of the above methods allows parametrised query. Either positional or named arguments.
+
+
Check a full working version:
+
+
require "db"
+require "sqlite3"
+
+DB .open "sqlite3:./file.db" do | db|
+ db.exec "create table contacts (name string, age integer)"
+ db.exec "insert into contacts values (?, ?)" , "John Doe" , 30
+
+ args = [] of DB :: Any
+ args << "Sarah"
+ args << 33
+ db.exec "insert into contacts values (?, ?)" , args
+
+ puts "max age:"
+ puts db.scalar "select max(age) from contacts" # => 33
+
+ puts "contacts:"
+ db.query "select name, age from contacts order by age desc" do | rs|
+ puts " #{ rs.column_name(0 )} (#{ rs.column_name(1 )} )"
+ # => name (age)
+ rs.each do
+ puts " #{ rs.read(String )} (#{ rs.read(Int32 )} )"
+ # => Sarah (33)
+ # => John Doe (30)
+ end
+ end
+end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db.cr
+
+
+
+
+
db/pool.cr
+
+
+
+
+
db/string_key_cache.cr
+
+
+
+
+
db/query_methods.cr
+
+
+
+
+
db/session_methods.cr
+
+
+
+
+
db/disposable.cr
+
+
+
+
+
db/driver.cr
+
+
+
+
+
db/statement.cr
+
+
+
+
+
db/begin_transaction.cr
+
+
+
+
+
db/connection_context.cr
+
+
+
+
+
db/connection.cr
+
+
+
+
+
db/transaction.cr
+
+
+
+
+
db/pool_statement.cr
+
+
+
+
+
db/database.cr
+
+
+
+
+
db/pool_prepared_statement.cr
+
+
+
+
+
db/pool_unprepared_statement.cr
+
+
+
+
+
db/result_set.cr
+
+
+
+
+
db/error.cr
+
+
+
+
+
db/mapping.cr
+
+
+
+
+
db/version.cr
+
+
+
+
+
+
+
+
Constant Summary
+
+
+
+
+ TYPES = [Nil , String , Bool , Int32 , Int64 , Float32 , Float64 , Time , Bytes ]
+
+
+
+ Types supported to interface with database driver.
+These can be used in any ResultSet#read
or any Database#query
related
+method to be used as query parameters
+
+
+
+
+ VERSION = "0.4.0"
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
+
+
Macro Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
connect (uri : URI | String)
+
+
#
+
+
+
Opens a connection using the specified uri .
+The scheme of the uri determines the driver to use.
+Returned connection must be closed by Connection#close
.
+If a block is used the connection is yielded and closed automatically.
+
+
+
+
+
+
+
+
+ def self.
connect (uri : URI | String, &block)
+
+
#
+
+
+
Opens a connection using the specified uri .
+The scheme of the uri determines the driver to use.
+Returned connection must be closed by Connection#close
.
+If a block is used the connection is yielded and closed automatically.
+
+
+
+
+
+
+
+
+ def self.
open (uri : URI | String)
+
+
#
+
+
+
Opens a database using the specified uri .
+The scheme of the uri determines the driver to use.
+Returned database must be closed by Database#close
.
+If a block is used the database is yielded and closed automatically.
+
+
+
+
+
+
+
+
+ def self.
open (uri : URI | String, &block)
+
+
#
+
+
+
Same as #open
but the database is yielded and closed automatically.
+
+
+
+
+
+
+
+
+ def self.
register_driver (driver_name, driver_class : Driver.class)
+
+
#
+
+
+
Registers a driver class for a given driver_name .
+Should be called by drivers implementors only.
+
+
+
+
+
+
+
+
+
+
+
Macro Detail
+
+
+
+
+ macro
mapping (properties, strict = true)
+
+
#
+
+
+
The DB.mapping
macro defines how an object is built from a DB::ResultSet.
+
+
It takes hash literal as argument, in which attributes and types are defined.
+Once defined, DB::ResultSet#read(t)
populates properties of the class from the
+result set.
+
+
require "db"
+
+class Employee
+ DB .mapping({
+ title: String ,
+ name: String ,
+ })
+end
+
+employees = Employee .from_rs(db.query("SELECT title, name FROM employees" ))
+employees[0 ].title # => "Manager"
+employees[0 ].name # => "John"
+
+
Attributes not mapped with DB.mapping
are not defined as properties.
+Also, missing attributes raise a DB::Exception
.
+
+
You can also define attributes for each property.
+
+
class Employee
+ DB .mapping({
+ title: String ,
+ name: {
+ type : String ,
+ nilable: true ,
+ key: "firstname" ,
+ },
+ })
+end
+
+
Available attributes:
+
+
type (required) defines its type. In the example above, title: String is a shortcut to title: {type: String} .nilable defines if a property can be a Nil
.default : value to use if the property is missing in the result set, or if it's null
and nilable
was not set to true
. If the default value creates a new instance of an object (for example [1, 2, 3]
or SomeObject.new
), a different instance will be used each time a row is parsed.key defines which column to read from a reusltset. It defaults to the name of the property.converter takes an alternate type for parsing. It requires a #from_rs
method in that class, and returns an instance of the given type.
+
+
The mapping also automatically defines Crystal properties (getters and setters) for each
+of the keys. It doesn't define a constructor accepting those arguments, but you can provide
+an overload.
+
+
The macro basically defines a constructor accepting a DB::ResultSet
that reads from
+it and initializes this type's instance variables.
+
+
This macro also declares instance variables of the types given in the mapping.
+
+
+
+
+
+
+
+
+ macro
mapping
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Any.html b/api/0.4.0/DB/Any.html
new file mode 100644
index 0000000..d5a5b38
--- /dev/null
+++ b/api/0.4.0/DB/Any.html
@@ -0,0 +1,265 @@
+
+
+
+
+
+
+
+ DB::Any - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ alias DB::Any
+
+
+
+
+
+
+
+
+
+
Alias Definition
+
Bool | Float32 | Float64 | Int32 | Int64 | Slice(UInt8) | String | Time | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/BeginTransaction.html b/api/0.4.0/DB/BeginTransaction.html
new file mode 100644
index 0000000..7e2350a
--- /dev/null
+++ b/api/0.4.0/DB/BeginTransaction.html
@@ -0,0 +1,336 @@
+
+
+
+
+
+
+
+ DB::BeginTransaction - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::BeginTransaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/begin_transaction.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+ def
transaction (&block)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Connection.html b/api/0.4.0/DB/Connection.html
new file mode 100644
index 0000000..be1339b
--- /dev/null
+++ b/api/0.4.0/DB/Connection.html
@@ -0,0 +1,540 @@
+
+
+
+
+
+
+
+ DB::Connection - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::Connection
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Database driver implementors must subclass Connection
.
+
+
Represents one active connection to a database.
+
+
Users should never instantiate a Connection
manually. Use DB#open
or Database#connection
.
+
+
Refer to QueryMethods
for documentation about querying the database through this connection.
+
+
Note to implementors
+
+
The connection must be initialized in #initialize
and closed in #do_close
.
+
+
Override #build_prepared_statement
method in order to return a prepared Statement
to allow querying.
+Override #build_unprepared_statement
method in order to return a unprepared Statement
to allow querying.
+See also Statement
to define how the statements are executed.
+
+
If at any give moment the connection is lost a DB::ConnectionLost should be raised. This will
+allow the connection pool to try to reconnect or use another connection if available.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/connection.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ begin_transaction : Transaction
+ begin_transaction ,
+
+
+
+ transaction(&block)
+ transaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ build(query) : Stmt
+ build ,
+
+
+
+ build_unprepared_statement(query) : Stmt
+ build_unprepared_statement ,
+
+
+
+ fetch_or_build_prepared_statement(query) : Stmt
+ fetch_or_build_prepared_statement ,
+
+
+
+ prepared(query) prepared
+ prepared ,
+
+
+
+ prepared_statements? : Bool
+ prepared_statements? ,
+
+
+
+ unprepared(query) unprepared
+ unprepared
+
+
+
+
+
+
+
+
+
+
+
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) forall 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 forall 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? forall U query_one?(query, *args, as types : Tuple) query_one?(query, *args, as type : Class)
+ query_one? ,
+
+
+
+ scalar(query, *args)
+ scalar
+
+
+
+
+
+
+
+
+
+
+
Instance methods inherited from module DB::Disposable
+
+
+
+ close
+ close ,
+
+
+
+ closed?
+ closed?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
begin_transaction
+
+
#
+
+
+
+
+
+
+
+
+
+ def
prepared_statements? : Bool
+
+
#
+
+
+
+
+
+
+
+
+
+
return this connection to the pool
+managed by the database. Should be used
+only if the connection was obtained by Database#checkout
.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/ConnectionContext.html b/api/0.4.0/DB/ConnectionContext.html
new file mode 100644
index 0000000..0f41316
--- /dev/null
+++ b/api/0.4.0/DB/ConnectionContext.html
@@ -0,0 +1,379 @@
+
+
+
+
+
+
+
+ DB::ConnectionContext - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::ConnectionContext
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/connection_context.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+ abstract
+ def
discard (connection :
Connection )
+
+
#
+
+
+
Indicates that the connection was permanently closed
+and should not be used in the future.
+
+
+
+
+
+
+
+ abstract
+ def
prepared_statements? : Bool
+
+
#
+
+
+
Return whether the statements should be prepared by default
+
+
+
+
+
+
+
+ abstract
+ def
release (connection :
Connection )
+
+
#
+
+
+
Indicates that the connection is no longer needed
+and can be reused in the future.
+
+
+
+
+
+
+
+ abstract
+ def
uri : URI
+
+
#
+
+
+
Returns the uri with the connection settings to the database
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/ConnectionLost.html b/api/0.4.0/DB/ConnectionLost.html
new file mode 100644
index 0000000..9c7f375
--- /dev/null
+++ b/api/0.4.0/DB/ConnectionLost.html
@@ -0,0 +1,356 @@
+
+
+
+
+
+
+
+ DB::ConnectionLost - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::ConnectionLost
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Raised when an established connection is lost
+probably due to socket/network issues.
+It is used by the connection pool retry logic.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (connection)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/ConnectionRefused.html b/api/0.4.0/DB/ConnectionRefused.html
new file mode 100644
index 0000000..abee9eb
--- /dev/null
+++ b/api/0.4.0/DB/ConnectionRefused.html
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+
+ DB::ConnectionRefused - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::ConnectionRefused
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Raised when a connection is unable to be established
+probably due to socket/network or configuration issues.
+It is used by the connection pool retry logic.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Database.html b/api/0.4.0/DB/Database.html
new file mode 100644
index 0000000..8ca9bc7
--- /dev/null
+++ b/api/0.4.0/DB/Database.html
@@ -0,0 +1,597 @@
+
+
+
+
+
+
+
+ DB::Database - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ 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:
+
+
initial_pool_size (default 1) max_pool_size (default 0 = unlimited) max_idle_pool_size (default 1) checkout_timeout (default 5.0) retry_attempts (default 1) retry_delay (in seconds, default 1.0)
+
+
When querying a database prepared statements are used by default.
+This can be changed from the prepared_statements
URI parameter:
+
+
prepared_statements = true
|false
(default true
)
+
+
It should be created from DB module. See DB#open
.
+
+
Refer to QueryMethods
and SessionMethods
for documentation about querying the database.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/database.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ discard(connection : Connection)
+ discard ,
+
+
+
+ prepared_statements? : Bool
+ prepared_statements? ,
+
+
+
+ release(connection : Connection)
+ release ,
+
+
+
+ uri : URI
+ uri
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ build(query) : Stmt
+ build ,
+
+
+
+ build_unprepared_statement(query) : Stmt
+ build_unprepared_statement ,
+
+
+
+ fetch_or_build_prepared_statement(query) : Stmt
+ fetch_or_build_prepared_statement ,
+
+
+
+ prepared(query) prepared
+ prepared ,
+
+
+
+ prepared_statements? : Bool
+ prepared_statements? ,
+
+
+
+ unprepared(query) unprepared
+ unprepared
+
+
+
+
+
+
+
+
+
+
+
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) forall 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 forall 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? forall U query_one?(query, *args, as types : Tuple) query_one?(query, *args, as type : Class)
+ query_one? ,
+
+
+
+ scalar(query, *args)
+ scalar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
returns a connection from the pool
+the returned connection must be returned
+to the pool by explictly calling Connection#release
+
+
+
+
+
+
+
+
+
Closes all connection to the database.
+
+
+
+
+
+
+
+
+ def
prepared_statements? : Bool
+
+
#
+
+
+
+
+
+
+
+
+
+ def
setup_connection (&proc :
Connection -> Nil)
+
+
#
+
+
+
+
+
+
+
+
+
+ def
transaction (&block)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+ def
uri : URI
+
+
#
+
+
+
Returns the uri with the connection settings to the database
+
+
+
+
+
+
+
+
+ def
using_connection (&block)
+
+
#
+
+
+
yields a connection from the pool
+the connection is returned to the pool
+when the block ends
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Disposable.html b/api/0.4.0/DB/Disposable.html
new file mode 100644
index 0000000..c354b12
--- /dev/null
+++ b/api/0.4.0/DB/Disposable.html
@@ -0,0 +1,337 @@
+
+
+
+
+
+
+
+ DB::Disposable - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::Disposable
+
+
+
+
+
+
+
+
Overview
+
+
Generic module to encapsulate disposable db resources.
+
+
+
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/disposable.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+ #close
+
+
+
+
+
+
+ #closed?
+
+ Returns true
if this object is closed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+
Returns true
if this object is closed. See #close
.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Driver.html b/api/0.4.0/DB/Driver.html
new file mode 100644
index 0000000..429f473
--- /dev/null
+++ b/api/0.4.0/DB/Driver.html
@@ -0,0 +1,353 @@
+
+
+
+
+
+
+
+ DB::Driver - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::Driver
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Database driver implementors must subclass Driver
,
+register with a driver_name using DB#register_driver
and
+override the factory method #build_connection
.
+
+
require "db"
+
+class FakeDriver < DB :: Driver
+ def build_connection (context : DB :: ConnectionContext )
+ FakeConnection .new context
+ end
+end
+
+DB .register_driver "fake" , FakeDriver
+
+
Access to this fake datbase will be available with
+
+
DB .open "fake://..." do | db|
+ # ... use db ...
+end
+
+
Refer to Connection
, Statement
and ResultSet
for further
+driver implementation instructions.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/driver.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+ def
connection_pool_options (params : HTTP::Params)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Error.html b/api/0.4.0/DB/Error.html
new file mode 100644
index 0000000..3fb541a
--- /dev/null
+++ b/api/0.4.0/DB/Error.html
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+
+ DB::Error - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::Error
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Direct Known Subclasses
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/ExecResult.html b/api/0.4.0/DB/ExecResult.html
new file mode 100644
index 0000000..c2b8d77
--- /dev/null
+++ b/api/0.4.0/DB/ExecResult.html
@@ -0,0 +1,385 @@
+
+
+
+
+
+
+
+ DB::ExecResult - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ struct DB::ExecResult
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Result of a #exec
statement.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (rows_affected : Int64, last_insert_id : Int64)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+ def
last_insert_id : Int64
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+ def
rows_affected : Int64
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Mappable.html b/api/0.4.0/DB/Mappable.html
new file mode 100644
index 0000000..bbc892d
--- /dev/null
+++ b/api/0.4.0/DB/Mappable.html
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+
+ DB::Mappable - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::Mappable
+
+
+
+
+
+
+
+
Overview
+
+
Empty module used for marking a class as supporting DB:Mapping
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/mapping.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/MappingException.html b/api/0.4.0/DB/MappingException.html
new file mode 100644
index 0000000..fb9cb7a
--- /dev/null
+++ b/api/0.4.0/DB/MappingException.html
@@ -0,0 +1,285 @@
+
+
+
+
+
+
+
+ DB::MappingException - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::MappingException
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Pool.html b/api/0.4.0/DB/Pool.html
new file mode 100644
index 0000000..695dc86
--- /dev/null
+++ b/api/0.4.0/DB/Pool.html
@@ -0,0 +1,438 @@
+
+
+
+
+
+
+
+ DB::Pool(T) - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::Pool(T)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/pool.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (initial_pool_size =
1 , max_pool_size =
0 , max_idle_pool_size =
1 , checkout_timeout =
5.0 , retry_attempts =
1 , retry_delay =
0.2 , &factory : -> T)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
checkout : T
+
+
#
+
+
+
+
+
+
+
+
+
+ def
checkout_some (candidates : Enumerable(WeakRef(T))) : ::Tuple(T, Bool)
+
+
#
+
+
+
selected, is_candidate = pool.checkout_some(candidates)
+
+
selected
be a resource from the candidates
list and is_candidate
== true
+or selected
will be a new resource adn is_candidate
== false
+
+
+
+
+
+
+
+
+ def
close : Nil
+
+
#
+
+
+
close all resources in the pool
+
+
+
+
+
+
+
+
+ def
release (resource : T) : Nil
+
+
#
+
+
+
+
+
+
+
+
+
+ def
retry (&block)
+
+
#
+
+
+
:nodoc:
+Will retry the block if a ConnectionLost
exception is thrown.
+It will try to reuse all of the available connection right away,
+but if a new connection is needed there is a retry_delay
seconds delay.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Pool/TimeoutHelper.html b/api/0.4.0/DB/Pool/TimeoutHelper.html
new file mode 100644
index 0000000..f08c380
--- /dev/null
+++ b/api/0.4.0/DB/Pool/TimeoutHelper.html
@@ -0,0 +1,378 @@
+
+
+
+
+
+
+
+ DB::Pool::TimeoutHelper - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::Pool::TimeoutHelper
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/pool.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (timeout : Float64)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+ def
receive_select_action
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/PoolPreparedStatement.html b/api/0.4.0/DB/PoolPreparedStatement.html
new file mode 100644
index 0000000..d415be1
--- /dev/null
+++ b/api/0.4.0/DB/PoolPreparedStatement.html
@@ -0,0 +1,397 @@
+
+
+
+
+
+
+
+ DB::PoolPreparedStatement - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::PoolPreparedStatement
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Represents a statement to be executed in any of the connections
+of the pool. The statement is not be executed in a prepared fashion.
+The execution of the statement is retried according to the pool configuration.
+
+
See PoolStatement
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/pool_prepared_statement.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (db :
Database , query : String)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/PoolRetryAttemptsExceeded.html b/api/0.4.0/DB/PoolRetryAttemptsExceeded.html
new file mode 100644
index 0000000..008955c
--- /dev/null
+++ b/api/0.4.0/DB/PoolRetryAttemptsExceeded.html
@@ -0,0 +1,292 @@
+
+
+
+
+
+
+
+ DB::PoolRetryAttemptsExceeded - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::PoolRetryAttemptsExceeded
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/PoolStatement.html b/api/0.4.0/DB/PoolStatement.html
new file mode 100644
index 0000000..16c2abe
--- /dev/null
+++ b/api/0.4.0/DB/PoolStatement.html
@@ -0,0 +1,560 @@
+
+
+
+
+
+
+
+ DB::PoolStatement - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::PoolStatement
+
+
+
+
+
+
+
+
+
+
Overview
+
+
When a statement is to be executed in a DB that has a connection pool
+a statement from the DB needs to be able to represent a statement in any
+of the connections of the pool. Otherwise the user will need to deal with
+actual connections in some point.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
Direct Known Subclasses
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/pool_statement.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (db :
Database , query : String)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def
scalar (*args)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/PoolTimeout.html b/api/0.4.0/DB/PoolTimeout.html
new file mode 100644
index 0000000..981769c
--- /dev/null
+++ b/api/0.4.0/DB/PoolTimeout.html
@@ -0,0 +1,292 @@
+
+
+
+
+
+
+
+ DB::PoolTimeout - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::PoolTimeout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/PoolUnpreparedStatement.html b/api/0.4.0/DB/PoolUnpreparedStatement.html
new file mode 100644
index 0000000..3e8fcec
--- /dev/null
+++ b/api/0.4.0/DB/PoolUnpreparedStatement.html
@@ -0,0 +1,397 @@
+
+
+
+
+
+
+
+ DB::PoolUnpreparedStatement - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::PoolUnpreparedStatement
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Represents a statement to be executed in any of the connections
+of the pool. The statement is not be executed in a non prepared fashion.
+The execution of the statement is retried according to the pool configuration.
+
+
See PoolStatement
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/pool_unprepared_statement.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (db :
Database , query : String)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/QueryMethods.html b/api/0.4.0/DB/QueryMethods.html
new file mode 100644
index 0000000..580f554
--- /dev/null
+++ b/api/0.4.0/DB/QueryMethods.html
@@ -0,0 +1,693 @@
+
+
+
+
+
+
+
+ DB::QueryMethods - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::QueryMethods
+
+
+
+
+
+
+
+
Overview
+
+
Methods to allow querying a database.
+All methods accepts a query : String
and a set arguments.
+
+
Three kind of statements can be performed:
+
+
#exec
waits no record response from the database. An ExecResult
is returned.#scalar
reads a single value of the response. A union of possible values is returned.#query
returns a ResultSet
that allows iteration over the rows in the response and column information.
+
+
Arguments can be passed by position
+
+
db.query("SELECT name FROM ... WHERE age > ?" , age)
+
+
Convention of mapping how arguments are mapped to the query depends on each driver.
+
+
Including QueryMethods
requires a build(query) : Statement
method that is not expected
+to be called directly.
+
+
+
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/query_methods.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+ #exec (query, *args)
+
+
+
+
+
+
+ #query (query, *args)
+
+ Executes a query and returns a ResultSet
with the results.
+
+
+
+
+ #query (query, *args, &block)
+
+ Executes a query and yields a ResultSet
with the results.
+
+
+
+
+ #query_all (query, *args, &block : ResultSet -> U) : Array(U) forall U
+
+ Executes a query and yield a ResultSet
positioned at the beginning of each row, returning an array of the values of the blocks.
+
+
+
+
+ #query_all (query, *args, as types : Tuple)
+
+ Executes a query and returns an array where each row is read as a tuple of the given types .
+
+
+
+
+ #query_all (query, *args, as type : Class)
+
+ Executes a query and returns an array where there first column's value of each row is read as the given type .
+
+
+
+
+ #query_one (query, *args, &block : ResultSet -> U) : U forall U
+
+ Executes a query that expects a single row and yields a ResultSet
positioned at that first row.
+
+
+
+
+ #query_one (query, *args, as types : Tuple)
+
+ Executes a query that expects a single row and returns it as a tuple of the given types .
+
+
+
+
+ #query_one (query, *args, as type : Class)
+
+ Executes a query that expects a single row and returns the first column's value as the given type .
+
+
+
+
+ #query_one? (query, *args, &block : ResultSet -> U) : U? forall U
+
+ Executes a query that expects at most a single row and yields a ResultSet
positioned at that first row.
+
+
+
+
+ #query_one? (query, *args, as types : Tuple)
+
+ Executes a query that expects a single row and returns it as a tuple of the given types .
+
+
+
+
+ #query_one? (query, *args, as type : Class)
+
+ Executes a query that expects a single row and returns the first column's value as the given type .
+
+
+
+
+ #scalar (query, *args)
+
+ Performs the #query
and returns a single scalar value puts db.scalar("SELECT MAX(name)").as(String) # => (a String)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
exec (query, *args)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+ def
query (query, *args)
+
+
#
+
+
+
Executes a query and returns a ResultSet
with the results.
+The ResultSet
must be closed manually.
+
+
result = db.query "select name from contacts where id = ?" , 10
+begin
+ if result.move_next
+ id = result.read(Int32 )
+ end
+ensure
+ result.close
+end
+
+
+
+
+
+
+
+
+ def
query (query, *args, &block)
+
+
#
+
+
+
Executes a query and yields a ResultSet
with the results.
+The ResultSet
is closed automatically.
+
+
db.query("select name from contacts where age > ?" , 18 ) do | rs|
+ rs.each do
+ name = rs.read(String )
+ end
+end
+
+
+
+
+
+
+
+
+ def
query_all (query, *args, &block :
ResultSet -> U) : Array(U) forall U
+
+
#
+
+
+
Executes a query and yield a ResultSet
positioned at the beginning
+of each row, returning an array of the values of the blocks.
+
+
names = db.query_all "select name from contacts" , & .read(String )
+
+
+
+
+
+
+
+
+ def
query_all (query, *args, as types : Tuple)
+
+
#
+
+
+
Executes a query and returns an array where each row is
+read as a tuple of the given types .
+
+
contacts = db.query_all "select name, age from contactas" , as : {String , Int32 }
+
+
+
+
+
+
+
+
+ def
query_all (query, *args, as type : Class)
+
+
#
+
+
+
Executes a query and returns an array where there first
+column's value of each row is read as the given type .
+
+
names = db.query_all "select name from contactas" , as : String
+
+
+
+
+
+
+
+
+ def
query_one (query, *args, &block :
ResultSet -> U) : U forall U
+
+
#
+
+
+
Executes a query that expects a single row and yields a ResultSet
+positioned at that first row.
+
+
The given block must not invoke move_next
on the yielded result set.
+
+
Raises DB::Error
if there were no rows, or if there were more than one row.
+
+
name = db.query_one "select name from contacts where id = ?" , 18 , & .read(String )
+
+
+
+
+
+
+
+
+ def
query_one (query, *args, as types : Tuple)
+
+
#
+
+
+
Executes a query that expects a single row and returns it
+as a tuple of the given types .
+
+
Raises DB::Error
if there were no rows, or if there were more than one row.
+
+
db.query_one "select name, age from contacts where id = ?" , 1 , as : {String , Int32 }
+
+
+
+
+
+
+
+
+ def
query_one (query, *args, as type : Class)
+
+
#
+
+
+
Executes a query that expects a single row
+and returns the first column's value as the given type .
+
+
Raises DB::Error
if there were no rows, or if there were more than one row.
+
+
db.query_one "select name from contacts where id = ?" , 1 , as : String
+
+
+
+
+
+
+
+
+ def
query_one? (query, *args, &block :
ResultSet -> U) : U? forall U
+
+
#
+
+
+
Executes a query that expects at most a single row and yields a ResultSet
+positioned at that first row.
+
+
Returns nil
, not invoking the block, if there were no rows.
+
+
Raises DB::Error
if there were more than one row
+(this ends up invoking the block once).
+
+
name = db.query_one? "select name from contacts where id = ?" , 18 , & .read(String )
+typeof (name) # => String | Nil
+
+
+
+
+
+
+
+
+ def
query_one? (query, *args, as types : Tuple)
+
+
#
+
+
+
Executes a query that expects a single row and returns it
+as a tuple of the given types .
+
+
Returns nil
if there were no rows.
+
+
Raises DB::Error
if there were more than one row.
+
+
result = db.query_one? "select name, age from contacts where id = ?" , 1 , as : {String , Int32 }
+typeof (result) # => Tuple(String, Int32) | Nil
+
+
+
+
+
+
+
+
+ def
query_one? (query, *args, as type : Class)
+
+
#
+
+
+
Executes a query that expects a single row
+and returns the first column's value as the given type .
+
+
Returns nil
if there were no rows.
+
+
Raises DB::Error
if there were more than one row.
+
+
name = db.query_one? "select name from contacts where id = ?" , 1 , as : String
+typeof (name) # => String?
+
+
+
+
+
+
+
+
+ def
scalar (query, *args)
+
+
#
+
+
+
Performs the #query
and returns a single scalar value
+puts db.scalar("SELECT MAX(name)").as(String) # => (a String)
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/ResultSet.html b/api/0.4.0/DB/ResultSet.html
new file mode 100644
index 0000000..def0244
--- /dev/null
+++ b/api/0.4.0/DB/ResultSet.html
@@ -0,0 +1,615 @@
+
+
+
+
+
+
+
+ DB::ResultSet - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::ResultSet
+
+
+
+
+
+
+
+
+
+
Overview
+
+
The response of a query performed on a Database
.
+
+
See DB
for a complete sample.
+
+
Each #read
call consumes the result and moves to the next column.
+Each column must be read in order.
+At any moment a #move_next
can be invoked, meaning to skip the
+remaining, or even all the columns, in the current row.
+Also it is not mandatory to consume the whole ResultSet
, hence an iteration
+through #each
or #move_next
can be stopped.
+
+
Note: depending on how the ResultSet
was obtained it might be mandatory an
+explicit call to #close
. Check QueryMethods#query
.
+
+
Note to implementors
+
+
Override #move_next
to move to the next row. Override #read
returning the next value in the row. (Optional) Override #read(t)
for some types t
for which custom logic other than a simple cast is needed. Override #column_count
, #column_name
.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/result_set.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+ abstract
+ def
column_count : Int32
+
+
#
+
+
+
Returns the number of columns in the result
+
+
+
+
+
+
+
+ abstract
+ def
column_name (index : Int32) : String
+
+
#
+
+
+
Returns the name of the column in index
0-based position.
+
+
+
+
+
+
+
+
+ def
column_names
+
+
#
+
+
+
Returns the name of the columns.
+
+
+
+
+
+
+
+
+ def
each (&block)
+
+
#
+
+
+
Iterates over all the rows
+
+
+
+
+
+
+
+
+ def
each_column (&block)
+
+
#
+
+
+
Iterates over all the columns
+
+
+
+
+
+
+
+ abstract
+ def
move_next : Bool
+
+
#
+
+
+
Move the next row in the result.
+Return false
if no more rows are available.
+See #each
+
+
+
+
+
+
+
+
+ def
read (type : DB::Mappable.class)
+
+
#
+
+
+
Reads the next columns and maps them to a class
+
+
+
+
+
+
+
+
+ def
read (type : T.class) : T forall T
+
+
#
+
+
+
Reads the next column value as a type
+
+
+
+
+
+
+
+ abstract
+ def
read
+
+
#
+
+
+
Reads the next column value
+
+
+
+
+
+
+
+
+ def
read (*types : Class)
+
+
#
+
+
+
Reads the next columns and returns a tuple of the values.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Rollback.html b/api/0.4.0/DB/Rollback.html
new file mode 100644
index 0000000..2d5c78b
--- /dev/null
+++ b/api/0.4.0/DB/Rollback.html
@@ -0,0 +1,285 @@
+
+
+
+
+
+
+
+ DB::Rollback - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::Rollback
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/error.cr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/SavePointTransaction.html b/api/0.4.0/DB/SavePointTransaction.html
new file mode 100644
index 0000000..1c07a72
--- /dev/null
+++ b/api/0.4.0/DB/SavePointTransaction.html
@@ -0,0 +1,514 @@
+
+
+
+
+
+
+
+ DB::SavePointTransaction - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::SavePointTransaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/transaction.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (parent :
Transaction , savepoint_name : String)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+
+
+
+
+ def
create_save_point_transaction (parent :
Transaction )
+
+
#
+
+
+
+
+
+
+
+
+
+ def
release_from_nested_transaction
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/SessionMethods.html b/api/0.4.0/DB/SessionMethods.html
new file mode 100644
index 0000000..3a82bb2
--- /dev/null
+++ b/api/0.4.0/DB/SessionMethods.html
@@ -0,0 +1,529 @@
+
+
+
+
+
+
+
+ DB::SessionMethods(Session, Stmt) - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::SessionMethods(Session, Stmt)
+
+
+
+
+
+
+
+
Overview
+
+
Methods that are shared accross session like objects:
+
+
+
+
Classes that includes this module are able to execute
+queries and statements in both prepared and unprepared fashion.
+
+
This module serves for dsl reuse over session like objects.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/session_methods.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) forall 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 forall 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? forall 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
build (query) : Stmt
+
+
#
+
+
+
+
+
+
+
+
+ abstract
+ def
build_unprepared_statement (query) : Stmt
+
+
#
+
+
+
+
+
+
+
+
+ abstract
+ def
fetch_or_build_prepared_statement (query) : Stmt
+
+
#
+
+
+
+
+
+
+
+
+
+ def
prepared (query)
+
+
#
+
+
+
Returns a prepared Statement
that has not been executed yet.
+
+
+
+
+
+
+
+
+
dsl helper to build prepared statements
+returns a value that includes QueryMethods
+
+
+
+
+
+
+
+ abstract
+ def
prepared_statements? : Bool
+
+
#
+
+
+
Returns whether by default the statements should
+be prepared or not.
+
+
+
+
+
+
+
+
+ def
unprepared (query)
+
+
#
+
+
+
Returns an unprepared Statement
that has not been executed yet.
+
+
+
+
+
+
+
+
+ def
unprepared
+
+
#
+
+
+
dsl helper to build unprepared statements
+returns a value that includes QueryMethods
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/SessionMethods/PreparedQuery.html b/api/0.4.0/DB/SessionMethods/PreparedQuery.html
new file mode 100644
index 0000000..88d0b62
--- /dev/null
+++ b/api/0.4.0/DB/SessionMethods/PreparedQuery.html
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+ DB::SessionMethods::PreparedQuery(Session, Stmt) - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ struct DB::SessionMethods::PreparedQuery(Session, Stmt)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/session_methods.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
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) forall 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 forall 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? forall U query_one?(query, *args, as types : Tuple) query_one?(query, *args, as type : Class)
+ query_one? ,
+
+
+
+ scalar(query, *args)
+ scalar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (session : Session)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
build (query) : Stmt
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/SessionMethods/UnpreparedQuery.html b/api/0.4.0/DB/SessionMethods/UnpreparedQuery.html
new file mode 100644
index 0000000..8b2ab19
--- /dev/null
+++ b/api/0.4.0/DB/SessionMethods/UnpreparedQuery.html
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+ DB::SessionMethods::UnpreparedQuery(Session, Stmt) - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ struct DB::SessionMethods::UnpreparedQuery(Session, Stmt)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/session_methods.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
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) forall 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 forall 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? forall U query_one?(query, *args, as types : Tuple) query_one?(query, *args, as type : Class)
+ query_one? ,
+
+
+
+ scalar(query, *args)
+ scalar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+ def self.
new (session : Session)
+
+
#
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
build (query) : Stmt
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Statement.html b/api/0.4.0/DB/Statement.html
new file mode 100644
index 0000000..cd2a26a
--- /dev/null
+++ b/api/0.4.0/DB/Statement.html
@@ -0,0 +1,549 @@
+
+
+
+
+
+
+
+ DB::Statement - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::Statement
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Represents a query in a Connection
.
+It should be created by QueryMethods
.
+
+
Note to implementors
+
+
Subclass Statements
Statements
are created from a custom driver Connection#prepare
method.#perform_query
executes a query that is expected to return a ResultSet
#perform_exec
executes a query that is expected to return an ExecResult
#do_close
is called to release the statement resources.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/statement.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+ def
exec (args : Array)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def
exec (*args)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+ def
query (args : Array)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def
query (*args)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+ def
release_connection
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/StatementMethods.html b/api/0.4.0/DB/StatementMethods.html
new file mode 100644
index 0000000..d0dc59d
--- /dev/null
+++ b/api/0.4.0/DB/StatementMethods.html
@@ -0,0 +1,512 @@
+
+
+
+
+
+
+
+ DB::StatementMethods - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ module DB::StatementMethods
+
+
+
+
+
+
+
+
Overview
+
+
Common interface for connection based statements
+and for connection pool statements.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
+
+
Direct including types
+
+
+
+
+
+
Defined in:
+
+
+
db/statement.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+ abstract
+ def
exec (args : Array) :
ExecResult
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def
query (*args, &block)
+
+
#
+
+
+
+
+
+
+
+
+
+
+ abstract
+ def
query (args : Array) :
ResultSet
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def
scalar (*args)
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/StringKeyCache.html b/api/0.4.0/DB/StringKeyCache.html
new file mode 100644
index 0000000..5197651
--- /dev/null
+++ b/api/0.4.0/DB/StringKeyCache.html
@@ -0,0 +1,349 @@
+
+
+
+
+
+
+
+ DB::StringKeyCache(T) - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::StringKeyCache(T)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/string_key_cache.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+ def
each_value (&block)
+
+
#
+
+
+
+
+
+
+
+
+
+ def
fetch (key : String, &block) : T
+
+
#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/TopLevelTransaction.html b/api/0.4.0/DB/TopLevelTransaction.html
new file mode 100644
index 0000000..4f1bda7
--- /dev/null
+++ b/api/0.4.0/DB/TopLevelTransaction.html
@@ -0,0 +1,472 @@
+
+
+
+
+
+
+
+ DB::TopLevelTransaction - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ class DB::TopLevelTransaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/transaction.cr
+
+
+
+
+
+
+
+
+
Class Method Summary
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
Class Method Detail
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/DB/Transaction.html b/api/0.4.0/DB/Transaction.html
new file mode 100644
index 0000000..3d56478
--- /dev/null
+++ b/api/0.4.0/DB/Transaction.html
@@ -0,0 +1,452 @@
+
+
+
+
+
+
+
+ DB::Transaction - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+ abstract class DB::Transaction
+
+
+
+
+
+
+
+
+
+
Overview
+
+
Transactions should be started from DB#transaction
, Connection#transaction
+or Connection#begin_transaction
.
+
+
Use Transaction#connection
to submit statements to the database.
+
+
Use Transaction#commit
or Transaction#rollback
to close the ongoing transaction
+explicitly. Or refer to BeginTransaction#transaction
for documentation on how to
+use #transaction(&block)
methods in DB
and Connection
.
+
+
Nested transactions are supported by using sql SAVEPOINT
. To start a nested
+transaction use Transaction#transaction
or Transaction#begin_transaction
.
+
+
+
+
+
+
Included Modules
+
+
+
+
+
+
+
Direct Known Subclasses
+
+
+
+
+
+
+
+
Defined in:
+
+
+
db/transaction.cr
+
+
+
+
+
+
+
+
+
+
+
Instance Method Summary
+
+
+
+
+
+
+
+
+
+
+
+
Instance Method Detail
+
+
+
+
+
commits the current transaction
+
+
+
+
+
+
+
+
+
+ abstract
+ def
release_from_nested_transaction
+
+
#
+
+
+
+
+
+
+
+
+
+
rollbacks the current transaction
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/0.4.0/css/style.css b/api/0.4.0/css/style.css
new file mode 100644
index 0000000..2994e37
--- /dev/null
+++ b/api/0.4.0/css/style.css
@@ -0,0 +1,432 @@
+html, body {
+ position: relative;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+}
+
+body {
+ font-family: "Avenir", "Tahoma", "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
+ color: #333;
+}
+
+a {
+ color: #263F6C;
+}
+
+a:visited {
+ color: #112750;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ margin: 35px 0 25px;
+ color: #444444;
+}
+
+h1.type-name {
+ color: #47266E;
+ margin: 20px 0 30px;
+ background-color: #F8F8F8;
+ padding: 10px 12px;
+ border: 1px solid #EBEBEB;
+ border-radius: 2px;
+}
+
+h2 {
+ border-bottom: 1px solid #E6E6E6;
+ padding-bottom: 5px;
+}
+
+#types-list, #main-content {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ overflow: auto;
+}
+
+#types-list {
+ left: 0;
+ width: 20%;
+ background-color: #2E1052;
+ padding: 0 0 30px;
+ box-shadow: inset -3px 0 4px rgba(0,0,0,.35);
+}
+
+#types-list #search-box {
+ padding: 8px 9px;
+}
+
+#types-list input {
+ display: block;
+ box-sizing: border-box;
+ margin: 0;
+ padding: 5px;
+ font: inherit;
+ font-family: inherit;
+ line-height: 1.2;
+ width: 100%;
+ border: 0;
+ outline: 0;
+ border-radius: 2px;
+ box-shadow: 0px 3px 5px rgba(0,0,0,.25);
+ transition: box-shadow .12s;
+}
+
+#types-list input:focus {
+ box-shadow: 0px 5px 6px rgba(0,0,0,.5);
+}
+
+#types-list input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
+ color: #C8C8C8;
+ font-size: 14px;
+ text-indent: 2px;
+}
+
+#types-list input::-moz-placeholder { /* Firefox 19+ */
+ color: #C8C8C8;
+ font-size: 14px;
+ text-indent: 2px;
+}
+
+#types-list input:-ms-input-placeholder { /* IE 10+ */
+ color: #C8C8C8;
+ font-size: 14px;
+ text-indent: 2px;
+}
+
+#types-list input:-moz-placeholder { /* Firefox 18- */
+ color: #C8C8C8;
+ font-size: 14px;
+ text-indent: 2px;
+}
+
+#types-list ul {
+ margin: 0;
+ padding: 0;
+ list-style: none outside;
+}
+
+#types-list li {
+ display: block;
+ position: relative;
+}
+
+#types-list li.hide {
+ display: none;
+}
+
+#types-list a {
+ display: block;
+ padding: 5px 15px 5px 30px;
+ text-decoration: none;
+ color: #F8F4FD;
+ transition: color .14s;
+}
+
+#types-list a:focus {
+ outline: 1px solid #D1B7F1;
+}
+
+#types-list .current > a,
+#types-list a:hover {
+ color: #866BA6;
+}
+
+#types-list li ul {
+ overflow: hidden;
+ height: 0;
+ max-height: 0;
+ transition: 1s ease-in-out;
+}
+
+
+#types-list li.parent {
+ padding-left: 30px;
+}
+
+#types-list li.parent::before {
+ box-sizing: border-box;
+ content: "▼";
+ display: block;
+ width: 30px;
+ height: 30px;
+ position: absolute;
+ top: 0;
+ left: 0;
+ text-align: center;
+ color: white;
+ font-size: 8px;
+ line-height: 30px;
+ transform: rotateZ(-90deg);
+ cursor: pointer;
+ transition: .2s linear;
+}
+
+
+#types-list li.parent > a {
+ padding-left: 0;
+}
+
+#types-list li.parent.open::before {
+ transform: rotateZ(0);
+}
+
+#types-list li.open > ul {
+ height: auto;
+ max-height: 1000em;
+}
+
+#main-content {
+ padding: 0 30px 30px 30px;
+ left: 20%;
+ right: 0;
+}
+
+.kind {
+ font-size: 60%;
+ color: #866BA6;
+}
+
+.superclass-hierarchy {
+ margin: -15px 0 30px 0;
+ padding: 0;
+ list-style: none outside;
+ font-size: 80%;
+}
+
+.superclass-hierarchy .superclass {
+ display: inline-block;
+ margin: 0 7px 0 0;
+ padding: 0;
+}
+
+.superclass-hierarchy .superclass + .superclass::before {
+ content: "<";
+ margin-right: 7px;
+}
+
+.other-types-list li {
+ display: inline-block;
+}
+
+.other-types-list,
+.list-summary {
+ margin: 0 0 30px 0;
+ padding: 0;
+ list-style: none outside;
+}
+
+.entry-const {
+ font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+}
+
+.entry-summary {
+ padding-bottom: 4px;
+}
+
+.superclass-hierarchy .superclass a,
+.other-type a,
+.entry-summary .signature {
+ padding: 4px 8px;
+ margin-bottom: 4px;
+ display: inline-block;
+ background-color: #f8f8f8;
+ color: #47266E;
+ border: 1px solid #f0f0f0;
+ text-decoration: none;
+ border-radius: 3px;
+ font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+ transition: background .15s, border-color .15s;
+}
+
+.superclass-hierarchy .superclass a:hover,
+.other-type a:hover,
+.entry-summary .signature:hover {
+ background: #D5CAE3;
+ border-color: #624288;
+}
+
+.entry-summary .summary {
+ padding-left: 32px;
+}
+
+.entry-summary .summary p {
+ margin: 12px 0 16px;
+}
+
+.entry-summary a {
+ text-decoration: none;
+}
+
+.entry-detail {
+ padding: 30px 0;
+}
+
+.entry-detail .signature {
+ position: relative;
+ padding: 5px 15px;
+ margin-bottom: 10px;
+ display: block;
+ border-radius: 5px;
+ background-color: #f8f8f8;
+ color: #47266E;
+ border: 1px solid #f0f0f0;
+ font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+ transition: .2s ease-in-out;
+}
+
+.entry-detail:target .signature {
+ background-color: #D5CAE3;
+ border: 1px solid #624288;
+}
+
+.entry-detail .signature .method-permalink {
+ position: absolute;
+ top: 0;
+ left: -35px;
+ padding: 5px 15px;
+ text-decoration: none;
+ font-weight: bold;
+ color: #624288;
+ opacity: .4;
+ transition: opacity .2s;
+}
+
+.entry-detail .signature .method-permalink:hover {
+ opacity: 1;
+}
+
+.entry-detail:target .signature .method-permalink {
+ opacity: 1;
+}
+
+.methods-inherited {
+ padding-right: 10%;
+ line-height: 1.5em;
+}
+
+.methods-inherited h3 {
+ margin-bottom: 4px;
+}
+
+.methods-inherited a {
+ display: inline-block;
+ text-decoration: none;
+ color: #47266E;
+}
+
+.methods-inherited a:hover {
+ text-decoration: underline;
+ color: #6C518B;
+}
+
+.methods-inherited .tooltip>span {
+ background: #D5CAE3;
+ padding: 4px 8px;
+ border-radius: 3px;
+ margin: -4px -8px;
+}
+
+.methods-inherited .tooltip * {
+ color: #47266E;
+}
+
+pre {
+ padding: 10px 20px;
+ margin-top: 4px;
+ border-radius: 3px;
+ line-height: 1.45;
+ overflow: auto;
+ color: #333;
+ background: #fdfdfd;
+ font-size: 14px;
+ border: 1px solid #eee;
+}
+
+code {
+ font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+}
+
+span.flag {
+ padding: 2px 4px 1px;
+ border-radius: 3px;
+ margin-right: 3px;
+ font-size: 11px;
+ border: 1px solid transparent;
+}
+
+span.flag.orange {
+ background-color: #EE8737;
+ color: #FCEBDD;
+ border-color: #EB7317;
+}
+
+span.flag.yellow {
+ background-color: #E4B91C;
+ color: #FCF8E8;
+ border-color: #B69115;
+}
+
+span.flag.green {
+ background-color: #469C14;
+ color: #E2F9D3;
+ border-color: #34700E;
+}
+
+span.flag.red {
+ background-color: #BF1919;
+ color: #F9ECEC;
+ border-color: #822C2C;
+}
+
+span.flag.purple {
+ background-color: #2E1052;
+ color: #ECE1F9;
+ border-color: #1F0B37;
+}
+
+.tooltip>span {
+ position: absolute;
+ opacity: 0;
+ display: none;
+ pointer-events: none;
+}
+
+.tooltip:hover>span {
+ display: inline-block;
+ opacity: 1;
+}
+
+.c {
+ color: #969896;
+}
+
+.n {
+ color: #0086b3;
+}
+
+.t {
+ color: #0086b3;
+}
+
+.s {
+ color: #183691;
+}
+
+.i {
+ color: #7f5030;
+}
+
+.k {
+ color: #a71d5d;
+}
+
+.o {
+ color: #a71d5d;
+}
+
+.m {
+ color: #795da3;
+}
diff --git a/api/0.4.0/index.html b/api/0.4.0/index.html
new file mode 100644
index 0000000..4385b04
--- /dev/null
+++ b/api/0.4.0/index.html
@@ -0,0 +1,275 @@
+
+
+
+
+
+
+
+ README - github.com/crystal-lang/crystal-db
+
+
+
+
+
+
+
+
+
crystal-db
+
+
Common db api for crystal. You will need to a specific driver to access a database.
+
+
+
+
Installation
+
+
Add this to your application's shard.yml
:
+
+
dependencies:
+ db:
+ github: crystal-lang/crystal-db
+
+
Documentation
+
+
+
+
Usage
+
+
Since this is an abstract db api, it's usage is through a concrete database driver.
+
+
require "db"
+require "sqlite3"
+
+DB .open "sqlite3:./file.db" do | db|
+ # When using the pg driver, use $1, $2, etc. instead of ?
+ db.exec "create table contacts (name string, age integer)"
+ db.exec "insert into contacts values (?, ?)" , "John Doe" , 30
+
+ args = [] of DB :: Any
+ args << "Sarah"
+ args << 33
+ db.exec "insert into contacts values (?, ?)" , args
+
+ puts "max age:"
+ puts db.scalar "select max(age) from contacts" # => 33
+
+ puts "contacts:"
+ db.query "select name, age from contacts order by age desc" do | rs|
+ puts " #{ rs.column_name(0 )} (#{ rs.column_name(1 )} )"
+ # => name (age)
+ rs.each do
+ puts " #{ rs.read(String )} (#{ rs.read(Int32 )} )"
+ # => Sarah (33)
+ # => John Doe (30)
+ end
+ end
+end
+
+
Roadmap
+
+
Issues not yet addressed
+
+
[x] Support non prepared statements. #25 [x] Time data type. (implementation details depends on actual drivers) [x] Data type extensibility. Allow each driver to extend the data types allowed. [x] Transactions & nested transactions. #27 [x] Connection pool. [ ] Direct access to IO
to avoid memory allocation for blobs.
+
+
Contributing
+
+
Fork it ( https://github.com/crystal-lang/crystal-db/fork ) Create your feature branch (git checkout -b my-new-feature) Commit your changes (git commit -am 'Add some feature') Push to the branch (git push origin my-new-feature) Create a new Pull Request
+
+
Contributors
+
+
bcardiff Brian J. Cardiff - creator, maintainer
+
+
+
diff --git a/api/0.4.0/js/doc.js b/api/0.4.0/js/doc.js
new file mode 100644
index 0000000..c7ee038
--- /dev/null
+++ b/api/0.4.0/js/doc.js
@@ -0,0 +1,111 @@
+document.addEventListener('DOMContentLoaded', function() {
+ var sessionStorage;
+ try {
+ sessionStorage = window.sessionStorage;
+ } catch (e) { }
+ if(!sessionStorage) {
+ sessionStorage = {
+ setItem: function() {},
+ getItem: function() {},
+ removeItem: function() {}
+ };
+ }
+
+ var repositoryName = document.getElementById('repository-name').getAttribute('content');
+ var typesList = document.getElementById('types-list');
+ var searchInput = document.getElementById('search-input');
+ var parents = document.querySelectorAll('#types-list li.parent');
+
+ for(var i = 0; i < parents.length; i++) {
+ var _parent = parents[i];
+ _parent.addEventListener('click', function(e) {
+ e.stopPropagation();
+
+ if(e.target.tagName.toLowerCase() == 'li') {
+ if(e.target.className.match(/open/)) {
+ sessionStorage.removeItem(e.target.getAttribute('data-id'));
+ e.target.className = e.target.className.replace(/ +open/g, '');
+ } else {
+ sessionStorage.setItem(e.target.getAttribute('data-id'), '1');
+ if(e.target.className.indexOf('open') == -1) {
+ e.target.className += ' open';
+ }
+ }
+ }
+ });
+
+ if(sessionStorage.getItem(_parent.getAttribute('data-id')) == '1') {
+ _parent.className += ' open';
+ }
+ };
+
+ var childMatch = function(type, regexp){
+ var types = type.querySelectorAll("ul li");
+ for (var j = 0; j < types.length; j ++) {
+ var t = types[j];
+ if(regexp.exec(t.getAttribute('data-name'))){ return true; };
+ };
+ return false;
+ };
+
+ var searchTimeout;
+ var performSearch = function() {
+ clearTimeout(searchTimeout);
+ searchTimeout = setTimeout(function() {
+ var text = searchInput.value;
+ var types = document.querySelectorAll('#types-list li');
+ var words = text.toLowerCase().split(/\s+/).filter(function(word) {
+ return word.length > 0;
+ });
+ var regexp = new RegExp(words.join('|'));
+
+ for(var i = 0; i < types.length; i++) {
+ var type = types[i];
+ if(words.length == 0 || regexp.exec(type.getAttribute('data-name')) || childMatch(type, regexp)) {
+ type.className = type.className.replace(/ +hide/g, '');
+ var is_parent = new RegExp("parent").exec(type.className);
+ var is_not_opened = !(new RegExp("open").exec(type.className));
+ if(childMatch(type,regexp) && is_parent && is_not_opened){
+ type.className += " open";
+ };
+ } else {
+ if(type.className.indexOf('hide') == -1) {
+ type.className += ' hide';
+ };
+ };
+ if(words.length == 0){
+ type.className = type.className.replace(/ +open/g, '');
+ };
+ }
+ }, 200);
+ };
+ if (searchInput.value.length > 0) {
+ performSearch();
+ }
+ searchInput.addEventListener('keyup', performSearch);
+ searchInput.addEventListener('input', performSearch);
+
+ typesList.onscroll = function() {
+ var y = typesList.scrollTop;
+ sessionStorage.setItem(repositoryName + '::types-list:scrollTop', y);
+ };
+
+ var initialY = parseInt(sessionStorage.getItem(repositoryName + '::types-list:scrollTop') + "", 10);
+ if(initialY > 0) {
+ typesList.scrollTop = initialY;
+ }
+
+ var scrollToEntryFromLocationHash = function() {
+ var hash = window.location.hash;
+ if (hash) {
+ var targetAnchor = unescape(hash.substr(1));
+ var targetEl = document.querySelectorAll('.entry-detail[id="' + targetAnchor + '"]');
+
+ if (targetEl && targetEl.length > 0) {
+ targetEl[0].offsetParent.scrollTop = targetEl[0].offsetTop;
+ }
+ }
+ };
+ window.addEventListener("hashchange", scrollToEntryFromLocationHash, false);
+ scrollToEntryFromLocationHash();
+});