publishing docs for 0.2.2

This commit is contained in:
Brian J. Cardiff 2016-12-21 18:12:40 -03:00
parent a32b8611e8
commit 029dcf53ba
24 changed files with 8025 additions and 0 deletions

532
api/0.2.2/DB.html Normal file
View file

@ -0,0 +1,532 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<title>DB - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="index.html">README</a></li>
</ul>
<ul>
<li class="parent current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">module</span> DB
</h1>
<h2>Overview</h2>
<p>The DB module is a unified interface to database access.
Database dialects is supported by custom database driver shards.
Check <a href="https://github.com/manastech/crystal-sqlite3" target="_blank">manastech/crystal-sqlite3</a> for example.</p>
<p>Drivers implementors check <code><a href="DB/Driver.html">Driver</a></code> class.</p>
<p>DB manage a connection pool. The connection pool can be configured by <code>URI</code> query. See <code><a href="DB/Database.html">Database</a></code>.</p>
<h3>Usage</h3>
<p>Assuming <code>crystal-sqlite3</code> is included a sqlite3 database can be opened with <code><a href="DB.html#open%28uri%3AURI%7CString%29-class-method">#open</a></code>.</p>
<pre><code>db <span class="o">=</span> <span class="t">DB</span>.open <span class="s">&quot;sqlite3:./path/to/db/file.db&quot;</span>
db.close</code></pre>
<p>If a block is given to <code><a href="DB.html#open%28uri%3AURI%7CString%29-class-method">#open</a></code> the database is closed automatically</p>
<pre><code><span class="t">DB</span>.open <span class="s">&quot;sqlite3:./file.db&quot;</span> <span class="k">do</span> <span class="o">|</span>db<span class="o">|</span>
<span class="c"># work with db</span>
<span class="k">end</span> <span class="c"># db is closed</span></code></pre>
<p>In the code above <code>db</code> is a <code><a href="DB/Database.html">Database</a></code>. Methods available for querying it are described in <code><a href="DB/QueryMethods.html">QueryMethods</a></code>.</p>
<p>Three kind of statements can be performed:</p>
<ol><li><code>Database#exec</code> waits no response from the database.</li><li><code>Database#scalar</code> reads a single value of the response.</li><li><code>Database#query</code> returns a ResultSet that allows iteration over the rows in the response and column information.</li></ol>
<p>All of the above methods allows parametrised query. Either positional or named arguments.</p>
<p>Check a full working version:</p>
<pre><code><span class="k">require</span> <span class="s">&quot;db&quot;</span>
<span class="k">require</span> <span class="s">&quot;sqlite3&quot;</span>
<span class="t">DB</span>.open <span class="s">&quot;sqlite3:./file.db&quot;</span> <span class="k">do</span> <span class="o">|</span>db<span class="o">|</span>
db.exec <span class="s">&quot;create table contacts &#40;name string, age integer&#41;&quot;</span>
db.exec <span class="s">&quot;insert into contacts values &#40;?, ?&#41;&quot;</span>, <span class="s">&quot;John Doe&quot;</span>, <span class="n">30</span>
args <span class="o">=</span> <span class="o">[]</span> <span class="k">of</span> <span class="t">DB</span><span class="t">::</span><span class="t">Any</span>
args <span class="o"><<</span> <span class="s">&quot;Sarah&quot;</span>
args <span class="o"><<</span> <span class="n">33</span>
db.exec <span class="s">&quot;insert into contacts values &#40;?, ?&#41;&quot;</span>, args
puts <span class="s">&quot;max age:&quot;</span>
puts db.scalar <span class="s">&quot;select max&#40;age&#41; from contacts&quot;</span> <span class="c"># &#61;&gt; 33</span>
puts <span class="s">&quot;contacts:&quot;</span>
db.query <span class="s">&quot;select name, age from contacts order by age desc&quot;</span> <span class="k">do</span> <span class="o">|</span>rs<span class="o">|</span>
puts <span class="s">&quot;</span><span class="i">#{</span></span>rs.column_name(<span class="n">0</span>)<span class="s"><span class="i">}</span> &#40;</span><span class="i">#{</span></span>rs.column_name(<span class="n">1</span>)<span class="s"><span class="i">}</span>&#41;&quot;</span>
<span class="c"># &#61;&gt; name &#40;age&#41;</span>
rs.each <span class="k">do</span>
puts <span class="s">&quot;</span><span class="i">#{</span></span>rs.read(<span class="t">String</span>)<span class="s"><span class="i">}</span> &#40;</span><span class="i">#{</span></span>rs.read(<span class="t">Int32</span>)<span class="s"><span class="i">}</span>&#41;&quot;</span>
<span class="c"># &#61;&gt; Sarah &#40;33&#41;</span>
<span class="c"># &#61;&gt; John Doe &#40;30&#41;</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span></code></pre>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L68" target="_blank">db.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L3" target="_blank">db/pool.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/string_key_cache.cr#L1" target="_blank">db/string_key_cache.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L1" target="_blank">db/query_methods.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/disposable.cr#L1" target="_blank">db/disposable.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L4" target="_blank">db/database.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/driver.cr#L1" target="_blank">db/driver.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/connection.cr#L1" target="_blank">db/connection.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L1" target="_blank">db/statement.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L1" target="_blank">db/pool_statement.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L1" target="_blank">db/result_set.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L1" target="_blank">db/error.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/mapping.cr#L1" target="_blank">db/mapping.cr</a>
<br/>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/version.cr#L1" target="_blank">db/version.cr</a>
<br/>
<h2>Constant Summary</h2>
<dl>
<dt class="entry-const" id="TYPES">
<strong>TYPES</strong> = <code>[<span class="t">Nil</span>, <span class="t">String</span>, <span class="t">Int32</span>, <span class="t">Int64</span>, <span class="t">Float32</span>, <span class="t">Float64</span>, <span class="t">Bytes</span>]</code>
</dt>
<dd class="entry-const-doc">
<p>Types supported to interface with database driver.
These can be used in any <code><a href="DB/ResultSet.html#read-instance-method">ResultSet#read</a></code> or any <code>Database#query</code> related
method to be used as query parameters</p>
</dd>
<dt class="entry-const" id="VERSION">
<strong>VERSION</strong> = <code><span class="s">&quot;0.2.2&quot;</span></code>
</dt>
</dl>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#open%28uri%3AURI%7CString%29-class-method" class="signature"><strong>.open</strong>(uri : URI | String)</a>
<div class="summary"><p>Opens a database using the specified <em>uri</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#open%28uri%3AURI%7CString%2C%26block%29-class-method" class="signature"><strong>.open</strong>(uri : URI | String, &block)</a>
<div class="summary"><p>Same as <code><a href="DB.html#open%28uri%3AURI%7CString%29-class-method">#open</a></code> but the database is yielded and closed automatically.</p></div>
</li>
<li class="entry-summary">
<a href="#register_driver%28driver_name%2Cdriver_class%3ADriver.class%29-class-method" class="signature"><strong>.register_driver</strong>(driver_name, driver_class : Driver.class)</a>
<div class="summary"><p>Registers a driver class for a given <em>driver_name</em>.</p></div>
</li>
</ul>
<h2>Macro Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#mapping%28properties%2Cstrict%3Dtrue%29-macro" class="signature"><strong>mapping</strong>(properties, strict = true)</a>
<div class="summary"><p>The <code><a href="DB.html#mapping-macro">DB.mapping</a></code> macro defines how an object is built from a DB::ResultSet.</p></div>
</li>
<li class="entry-summary">
<a href="#mapping-macro" class="signature"><strong>mapping</strong></a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="open&#40;uri:URI|String&#41;-class-method">
<div class="signature">
def self.<strong>open</strong>(uri : URI | String)
<a class="method-permalink" href="#open%28uri%3AURI%7CString%29-class-method">#</a>
</div>
<div class="doc"><p>Opens a database using the specified <em>uri</em>.
The scheme of the <em>uri</em> determines the driver to use.
Returned database must be closed by <code><a href="DB/Database.html#close-instance-method">Database#close</a></code>.
If a block is used the database is yielded and closed automatically.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L102" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="open&#40;uri:URI|String,&amp;block&#41;-class-method">
<div class="signature">
def self.<strong>open</strong>(uri : URI | String, &block)
<a class="method-permalink" href="#open%28uri%3AURI%7CString%2C%26block%29-class-method">#</a>
</div>
<div class="doc"><p>Same as <code><a href="DB.html#open%28uri%3AURI%7CString%29-class-method">#open</a></code> but the database is yielded and closed automatically.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L107" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="register_driver&#40;driver_name,driver_class:Driver.class&#41;-class-method">
<div class="signature">
def self.<strong>register_driver</strong>(driver_name, driver_class : Driver.class)
<a class="method-permalink" href="#register_driver%28driver_name%2Cdriver_class%3ADriver.class%29-class-method">#</a>
</div>
<div class="doc"><p>Registers a driver class for a given <em>driver_name</em>.
Should be called by drivers implementors only.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L90" target="_blank">View source</a>]
</div>
</div>
<h2>Macro Detail</h2>
<div class="entry-detail" id="mapping&#40;properties,strict&#61;true&#41;-macro">
<div class="signature">
macro <strong>mapping</strong>(properties, strict = true)
<a class="method-permalink" href="#mapping%28properties%2Cstrict%3Dtrue%29-macro">#</a>
</div>
<div class="doc"><p>The <code><a href="DB.html#mapping-macro">DB.mapping</a></code> macro defines how an object is built from a DB::ResultSet.</p>
<p>It takes hash literal as argument, in which attributes and types are defined.
Once defined, <code><a href="DB/ResultSet.html#read%28type%3ADB%3A%3AMappable.class%29-instance-method">DB::ResultSet#read(t)</a></code> populates properties of the class from the
result set.</p>
<pre><code class='language-crystal'><span class="k">require</span> <span class="s">&quot;db&quot;</span>
<span class="k">class</span> <span class="t">Employee</span>
<span class="t">DB</span>.mapping({
title: <span class="t">String</span>,
name: <span class="t">String</span>,
})
<span class="k">end</span>
employees <span class="o">=</span> <span class="t">Employee</span>.from_rs(db.query(<span class="s">&quot;SELECT title, name FROM employees&quot;</span>))
employees[<span class="n">0</span>].title <span class="c"># &#61;&gt; &quot;Manager&quot;</span>
employees[<span class="n">0</span>].name <span class="c"># &#61;&gt; &quot;John&quot;</span></code></pre>
<p>Attributes not mapped with <code><a href="DB.html#mapping-macro">DB.mapping</a></code> are not defined as properties.
Also, missing attributes raise a <code>DB::Exception</code>.</p>
<p>You can also define attributes for each property.</p>
<pre><code class='language-crystal'><span class="k">class</span> <span class="t">Employee</span>
<span class="t">DB</span>.mapping({
title: <span class="t">String</span>,
name: {
<span class="k">type</span>: <span class="t">String</span>,
nilable: <span class="n">true</span>,
key: <span class="s">&quot;firstname&quot;</span>,
},
})
<span class="k">end</span></code></pre>
<p>Available attributes:</p>
<ul><li><em>type</em> (required) defines its type. In the example above, <em>title: String</em> is a shortcut to <em>title: {type: String}</em>.</li><li><em>nilable</em> defines if a property can be a <code>Nil</code>.</li><li><strong>default</strong>: value to use if the property is missing in the result set, or if it's <code>null</code> and <code>nilable</code> was not set to <code>true</code>. If the default value creates a new instance of an object (for example <code>[1, 2, 3]</code> or <code>SomeObject.new</code>), a different instance will be used each time a row is parsed.</li><li><em>key</em> defines which column to read from a reusltset. It defaults to the name of the property.</li><li><em>converter</em> takes an alternate type for parsing. It requires a <code>#from_rs</code> method in that class, and returns an instance of the given type.</li></ul>
<p>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.</p>
<p>The macro basically defines a constructor accepting a <code><a href="DB/ResultSet.html">DB::ResultSet</a></code> that reads from
it and initializes this type's instance variables.</p>
<p>This macro also declares instance variables of the types given in the mapping.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/mapping.cr#L60" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="mapping-macro">
<div class="signature">
macro <strong>mapping</strong>
<a class="method-permalink" href="#mapping-macro">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/mapping.cr#L140" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

200
api/0.2.2/DB/Any.html Normal file
View file

@ -0,0 +1,200 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Any - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">alias</span> DB::Any
</h1>
<h2>Alias Definition</h2>
<code>Float32 | Float64 | Int32 | Int64 | Slice(UInt8) | String | Nil</code>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L75" target="_blank">db.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,362 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Connection - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">abstract class</span> DB::Connection
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Connection.html">DB::Connection</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>Database driver implementors must subclass <code><a href="../DB/Connection.html">Connection</a></code>.</p>
<p>Represents one active connection to a database.</p>
<p>Users should never instantiate a <code><a href="../DB/Connection.html">Connection</a></code> manually. Use <code><a href="../DB.html#open%28uri%3AURI%7CString%29-class-method">DB#open</a></code> or <code>Database#connection</code>.</p>
<p>Refer to <code><a href="../DB/QueryMethods.html">QueryMethods</a></code> for documentation about querying the database through this connection.</p>
<h3>Note to implementors</h3>
<p>The connection must be initialized in <code>#initialize</code> and closed in <code>#do_close</code>.</p>
<p>Override <code><a href="../DB/Connection.html#build_statement%28query%29%3AStatement-instance-method">#build_statement</a></code> method in order to return a prepared <code><a href="../DB/Statement.html">Statement</a></code> to allow querying.
See also <code><a href="../DB/Statement.html">Statement</a></code> to define how the statements are executed.</p>
<p>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.</p>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/Disposable.html">DB::Disposable</a></li>
<li class="other-type"><a href="../DB/QueryMethods.html">DB::QueryMethods</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/connection.cr#L20" target="_blank">db/connection.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28database%3ADatabase%29-class-method" class="signature"><strong>.new</strong>(database : Database)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#build_statement%28query%29%3AStatement-instance-method" class="signature"><strong>#build_statement</strong>(query) : Statement</a>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/QueryMethods.html">DB::QueryMethods</a></code></h3>
<a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>exec(query, *args)</span>
exec</a>,
<a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>query(query, *args)<br/>query(query, *args, &block)</span>
query</a>,
<a href="../DB/QueryMethods.html#query_all%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AArray%28U%29-instance-method" class="tooltip">
<span>query_all(query, *args, &block : ResultSet -> U) : Array(U)<br/>query_all(query, *args, as types : Tuple)<br/>query_all(query, *args, as type : Class)</span>
query_all</a>,
<a href="../DB/QueryMethods.html#query_one%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU-instance-method" class="tooltip">
<span>query_one(query, *args, &block : ResultSet -> U) : U<br/>query_one(query, *args, as types : Tuple)<br/>query_one(query, *args, as type : Class)</span>
query_one</a>,
<a href="../DB/QueryMethods.html#query_one%3F%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU%3F-instance-method" class="tooltip">
<span>query_one?(query, *args, &block : ResultSet -> U) : U?<br/>query_one?(query, *args, as types : Tuple)<br/>query_one?(query, *args, as type : Class)</span>
query_one?</a>,
<a href="../DB/QueryMethods.html#scalar%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>scalar(query, *args)</span>
scalar</a>
<h3>Instance methods inherited from module <code><a href="../DB/Disposable.html">DB::Disposable</a></code></h3>
<a href="../DB/Disposable.html#close-instance-method" class="tooltip">
<span>close</span>
close</a>,
<a href="../DB/Disposable.html#closed%3F-instance-method" class="tooltip">
<span>closed?</span>
closed?</a>
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;database:Database&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(database : <a href="../DB/Database.html">Database</a>)
<a class="method-permalink" href="#new%28database%3ADatabase%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/connection.cr#L28" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="build_statement&#40;query&#41;:Statement-instance-method">
<div class="signature">
abstract
def <strong>build_statement</strong>(query) : <a href="../DB/Statement.html">Statement</a>
<a class="method-permalink" href="#build_statement%28query%29%3AStatement-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/connection.cr#L36" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,285 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::ConnectionLost - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::ConnectionLost
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/ConnectionLost.html">DB::ConnectionLost</a></li><li class="superclass"><a href="../DB/Error.html">DB::Error</a></li><li class="superclass">Exception</li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L14" target="_blank">db/error.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28connection%29-class-method" class="signature"><strong>.new</strong>(connection)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#connection%3AConnection-instance-method" class="signature"><strong>#connection</strong> : Connection</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;connection&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(connection)
<a class="method-permalink" href="#new%28connection%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L17" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="connection:Connection-instance-method">
<div class="signature">
def <strong>connection</strong> : <a href="../DB/Connection.html">Connection</a>
<a class="method-permalink" href="#connection%3AConnection-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L15" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

379
api/0.2.2/DB/Database.html Normal file
View file

@ -0,0 +1,379 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Database - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::Database
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Database.html">DB::Database</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>Acts as an entry point for database access.
Connections are managed by a pool.
The connection pool can be configured from URI parameters:</p>
<ul><li>initial_pool_size (default 1)</li><li>max_pool_size (default 0 = unlimited)</li><li>max_idle_pool_size (default 1)</li><li>checkout_timeout (default 5.0)</li><li>retry_attempts (default 1)</li><li>retry_delay (in seconds, default 1.0)</li></ul></ul>
<p>It should be created from DB module. See <code><a href="../DB.html#open%28uri%3AURI%7CString%29-class-method">DB#open</a></code>.</p>
<p>Refer to <code><a href="../DB/QueryMethods.html">QueryMethods</a></code> for documentation about querying the database.</p>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/QueryMethods.html">DB::QueryMethods</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L19" target="_blank">db/database.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#close-instance-method" class="signature"><strong>#close</strong></a>
<div class="summary"><p>Closes all connection to the database.</p></div>
</li>
<li class="entry-summary">
<a href="#setup_connection%28%26proc%3AConnection-%3ENil%29-instance-method" class="signature"><strong>#setup_connection</strong>(&proc : Connection -> Nil)</a>
</li>
<li class="entry-summary">
<a href="#uri%3AURI-instance-method" class="signature"><strong>#uri</strong> : URI</a>
<div class="summary"><p>Returns the uri with the connection settings to the database</p></div>
</li>
<li class="entry-summary">
<a href="#using_connection%28%26block%29-instance-method" class="signature"><strong>#using_connection</strong>(&block)</a>
<div class="summary"><p>yields a connection from the pool the connection is returned to the pool after when the block ends</p></div>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/QueryMethods.html">DB::QueryMethods</a></code></h3>
<a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>exec(query, *args)</span>
exec</a>,
<a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>query(query, *args)<br/>query(query, *args, &block)</span>
query</a>,
<a href="../DB/QueryMethods.html#query_all%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AArray%28U%29-instance-method" class="tooltip">
<span>query_all(query, *args, &block : ResultSet -> U) : Array(U)<br/>query_all(query, *args, as types : Tuple)<br/>query_all(query, *args, as type : Class)</span>
query_all</a>,
<a href="../DB/QueryMethods.html#query_one%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU-instance-method" class="tooltip">
<span>query_one(query, *args, &block : ResultSet -> U) : U<br/>query_one(query, *args, as types : Tuple)<br/>query_one(query, *args, as type : Class)</span>
query_one</a>,
<a href="../DB/QueryMethods.html#query_one%3F%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU%3F-instance-method" class="tooltip">
<span>query_one?(query, *args, &block : ResultSet -> U) : U?<br/>query_one?(query, *args, as types : Tuple)<br/>query_one?(query, *args, as type : Class)</span>
query_one?</a>,
<a href="../DB/QueryMethods.html#scalar%28query%2C%2Aargs%29-instance-method" class="tooltip">
<span>scalar(query, *args)</span>
scalar</a>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="close-instance-method">
<div class="signature">
def <strong>close</strong>
<a class="method-permalink" href="#close-instance-method">#</a>
</div>
<div class="doc"><p>Closes all connection to the database.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L54" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="setup_connection&#40;&amp;proc:Connection-&gt;Nil&#41;-instance-method">
<div class="signature">
def <strong>setup_connection</strong>(&proc : <a href="../DB/Connection.html">Connection</a> -> Nil)
<a class="method-permalink" href="#setup_connection%28%26proc%3AConnection-%3ENil%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L46" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="uri:URI-instance-method">
<div class="signature">
def <strong>uri</strong> : URI
<a class="method-permalink" href="#uri%3AURI-instance-method">#</a>
</div>
<div class="doc"><p>Returns the uri with the connection settings to the database</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L26" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="using_connection&#40;&amp;block&#41;-instance-method">
<div class="signature">
def <strong>using_connection</strong>(&block)
<a class="method-permalink" href="#using_connection%28%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>yields a connection from the pool
the connection is returned to the pool after
when the block ends</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/database.cr#L79" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,270 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Disposable - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">module</span> DB::Disposable
</h1>
<h2>Overview</h2>
<p>Generic module to encapsulate disposable db resources.</p>
<h2>Direct including types</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/Connection.html">DB::Connection</a></li>
<li class="other-type"><a href="../DB/ResultSet.html">DB::ResultSet</a></li>
<li class="other-type"><a href="../DB/StatementMethods.html">DB::StatementMethods</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/disposable.cr#L3" target="_blank">db/disposable.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#close-instance-method" class="signature"><strong>#close</strong></a>
<div class="summary"><p>Closes this object.</p></div>
</li>
<li class="entry-summary">
<a href="#closed%3F-instance-method" class="signature"><strong>#closed?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this object is closed.</p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="close-instance-method">
<div class="signature">
def <strong>close</strong>
<a class="method-permalink" href="#close-instance-method">#</a>
</div>
<div class="doc"><p>Closes this object.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/disposable.cr#L9" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="closed?-instance-method">
<div class="signature">
def <strong>closed?</strong>
<a class="method-permalink" href="#closed%3F-instance-method">#</a>
</div>
<div class="doc"><p>Returns <code>true</code> if this object is closed. See <code><a href="../DB/Disposable.html#close-instance-method">#close</a></code>.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/disposable.cr#L16" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

288
api/0.2.2/DB/Driver.html Normal file
View file

@ -0,0 +1,288 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Driver - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">abstract class</span> DB::Driver
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Driver.html">DB::Driver</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>Database driver implementors must subclass <code><a href="../DB/Driver.html">Driver</a></code>,
register with a driver_name using <code><a href="../DB.html#register_driver%28driver_name%2Cdriver_class%3ADriver.class%29-class-method">DB#register_driver</a></code> and
override the factory method <code><a href="../DB/Driver.html#build_connection%28db%3ADatabase%29%3AConnection-instance-method">#build_connection</a></code>.</p>
<pre><code><span class="k">require</span> <span class="s">&quot;db&quot;</span>
<span class="k">class</span> <span class="t">FakeDriver</span> <span class="o"><</span> <span class="t">Driver</span>
<span class="k">def</span> <span class="m">build_connection</span>(db)
<span class="t">FakeConnection</span>.<span class="k">new</span> db
<span class="k">end</span>
<span class="k">end</span>
<span class="t">DB</span>.register_driver <span class="s">&quot;fake&quot;</span>, <span class="t">FakeDriver</span></code></pre>
<p>Access to this fake datbase will be available with</p>
<pre><code><span class="t">DB</span>.open <span class="s">&quot;fake://...&quot;</span> <span class="k">do</span> <span class="o">|</span>db<span class="o">|</span>
<span class="c"># ... use db ...</span>
<span class="k">end</span></code></pre>
<p>Refer to <code><a href="../DB/Connection.html">Connection</a></code>, <code><a href="../DB/Statement.html">Statement</a></code> and <code><a href="../DB/ResultSet.html">ResultSet</a></code> for further
driver implementation instructions.</p>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/driver.cr#L28" target="_blank">db/driver.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#build_connection%28db%3ADatabase%29%3AConnection-instance-method" class="signature"><strong>#build_connection</strong>(db : Database) : Connection</a>
</li>
<li class="entry-summary">
<a href="#connection_pool_options%28params%3AHTTP%3A%3AParams%29-instance-method" class="signature"><strong>#connection_pool_options</strong>(params : HTTP::Params)</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="build_connection&#40;db:Database&#41;:Connection-instance-method">
<div class="signature">
abstract
def <strong>build_connection</strong>(db : <a href="../DB/Database.html">Database</a>) : <a href="../DB/Connection.html">Connection</a>
<a class="method-permalink" href="#build_connection%28db%3ADatabase%29%3AConnection-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/driver.cr#L29" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="connection_pool_options&#40;params:HTTP::Params&#41;-instance-method">
<div class="signature">
def <strong>connection_pool_options</strong>(params : HTTP::Params)
<a class="method-permalink" href="#connection_pool_options%28params%3AHTTP%3A%3AParams%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/driver.cr#L31" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

231
api/0.2.2/DB/Error.html Normal file
View file

@ -0,0 +1,231 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Error - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::Error
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Error.html">DB::Error</a></li><li class="superclass">Exception</li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Direct Known Subclasses</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/ConnectionLost.html">DB::ConnectionLost</a></li>
<li class="other-type"><a href="../DB/PoolRetryAttemptsExceeded.html">DB::PoolRetryAttemptsExceeded</a></li>
<li class="other-type"><a href="../DB/PoolTimeout.html">DB::PoolTimeout</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L2" target="_blank">db/error.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,320 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::ExecResult - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">struct</span> DB::ExecResult
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/ExecResult.html">DB::ExecResult</a></li><li class="superclass">Struct</li><li class="superclass">Value</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>Result of a <code>#exec</code> statement.</p>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L80" target="_blank">db.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28rows_affected%3AInt64%2Clast_insert_id%3AInt64%29-class-method" class="signature"><strong>.new</strong>(rows_affected : Int64, last_insert_id : Int64)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#clone-instance-method" class="signature"><strong>#clone</strong></a>
</li>
<li class="entry-summary">
<a href="#last_insert_id%3AInt64-instance-method" class="signature"><strong>#last_insert_id</strong> : Int64</a>
</li>
<li class="entry-summary">
<a href="#rows_affected%3AInt64-instance-method" class="signature"><strong>#rows_affected</strong> : Int64</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;rows_affected:Int64,last_insert_id:Int64&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(rows_affected : Int64, last_insert_id : Int64)
<a class="method-permalink" href="#new%28rows_affected%3AInt64%2Clast_insert_id%3AInt64%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L80" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="clone-instance-method">
<div class="signature">
def <strong>clone</strong>
<a class="method-permalink" href="#clone-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db.cr#L80" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="last_insert_id:Int64-instance-method">
<div class="signature">
def <strong>last_insert_id</strong> : Int64
<a class="method-permalink" href="#last_insert_id%3AInt64-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="rows_affected:Int64-instance-method">
<div class="signature">
def <strong>rows_affected</strong> : Int64
<a class="method-permalink" href="#rows_affected%3AInt64-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>

201
api/0.2.2/DB/Mappable.html Normal file
View file

@ -0,0 +1,201 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Mappable - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">module</span> DB::Mappable
</h1>
<h2>Overview</h2>
<p>Empty module used for marking a class as supporting DB:Mapping</p>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/mapping.cr#L3" target="_blank">db/mapping.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,220 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::MappingException - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::MappingException
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/MappingException.html">DB::MappingException</a></li><li class="superclass">Exception</li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L5" target="_blank">db/error.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

373
api/0.2.2/DB/Pool.html Normal file
View file

@ -0,0 +1,373 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Pool(T) - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent current" data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::Pool(T)
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Pool.html">DB::Pool(T)</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L4" target="_blank">db/pool.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28initial_pool_size%3D1%2Cmax_pool_size%3D0%2Cmax_idle_pool_size%3D1%2Ccheckout_timeout%3D5.0%2Cretry_attempts%3D1%2Cretry_delay%3D0.2%2C%26factory%3A-%3ET%29-class-method" class="signature"><strong>.new</strong>(initial_pool_size = <span class="n">1</span>, max_pool_size = <span class="n">0</span>, max_idle_pool_size = <span class="n">1</span>, checkout_timeout = <span class="n">5.0</span>, retry_attempts = <span class="n">1</span>, retry_delay = <span class="n">0.2</span>, &factory : -> T)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#checkout%3AT-instance-method" class="signature"><strong>#checkout</strong> : T</a>
</li>
<li class="entry-summary">
<a href="#checkout_some%28candidates%3AEnumerable%28WeakRef%28T%29%29%29%3A%3A%3ATuple%28T%2CBool%29-instance-method" class="signature"><strong>#checkout_some</strong>(candidates : Enumerable(WeakRef(T))) : ::Tuple(T, Bool)</a>
<div class="summary"><pre><code class='language-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`'></code></pre></div>
</li>
<li class="entry-summary">
<a href="#close%3ANil-instance-method" class="signature"><strong>#close</strong> : Nil</a>
<div class="summary"><p>close all resources in the pool</p></div>
</li>
<li class="entry-summary">
<a href="#release%28resource%3AT%29%3ANil-instance-method" class="signature"><strong>#release</strong>(resource : T) : Nil</a>
</li>
<li class="entry-summary">
<a href="#retry%28%26block%29-instance-method" class="signature"><strong>#retry</strong>(&block)</a>
<div class="summary"><p>:nodoc: Will retry the block if a <code><a href="../DB/ConnectionLost.html">ConnectionLost</a></code> exception is thrown.</p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;initial_pool_size&#61;1,max_pool_size&#61;0,max_idle_pool_size&#61;1,checkout_timeout&#61;5.0,retry_attempts&#61;1,retry_delay&#61;0.2,&amp;factory:-&gt;T&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(initial_pool_size = <span class="n">1</span>, max_pool_size = <span class="n">0</span>, max_idle_pool_size = <span class="n">1</span>, checkout_timeout = <span class="n">5.0</span>, retry_attempts = <span class="n">1</span>, retry_delay = <span class="n">0.2</span>, &factory : -> T)
<a class="method-permalink" href="#new%28initial_pool_size%3D1%2Cmax_pool_size%3D0%2Cmax_idle_pool_size%3D1%2Ccheckout_timeout%3D5.0%2Cretry_attempts%3D1%2Cretry_delay%3D0.2%2C%26factory%3A-%3ET%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L15" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="checkout:T-instance-method">
<div class="signature">
def <strong>checkout</strong> : T
<a class="method-permalink" href="#checkout%3AT-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L31" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="checkout_some&#40;candidates:Enumerable&#40;WeakRef&#40;T&#41;&#41;&#41;:::Tuple&#40;T,Bool&#41;-instance-method">
<div class="signature">
def <strong>checkout_some</strong>(candidates : Enumerable(WeakRef(T))) : ::Tuple(T, Bool)
<a class="method-permalink" href="#checkout_some%28candidates%3AEnumerable%28WeakRef%28T%29%29%29%3A%3A%3ATuple%28T%2CBool%29-instance-method">#</a>
</div>
<div class="doc"><pre><code>selected, is_candidate <span class="o">=</span> pool.checkout_some(candidates)</code></pre>
<p><code>selected</code> be a resource from the <code>candidates</code> list and <code>is_candidate</code> == <code>true</code>
or <code>selected</code> will be a new resource adn <code>is_candidate</code> == <code>false</code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L52" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="close:Nil-instance-method">
<div class="signature">
def <strong>close</strong> : Nil
<a class="method-permalink" href="#close%3ANil-instance-method">#</a>
</div>
<div class="doc"><p>close all resources in the pool</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L25" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="release&#40;resource:T&#41;:Nil-instance-method">
<div class="signature">
def <strong>release</strong>(resource : T) : Nil
<a class="method-permalink" href="#release%28resource%3AT%29%3ANil-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L67" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="retry&#40;&amp;block&#41;-instance-method">
<div class="signature">
def <strong>retry</strong>(&block)
<a class="method-permalink" href="#retry%28%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>:nodoc:
Will retry the block if a <code><a href="../DB/ConnectionLost.html">ConnectionLost</a></code> 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 <code>retry_delay</code> seconds delay.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L81" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,313 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/doc.js"></script>
<title>DB::Pool::TimeoutHelper - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../../DB/MappingException.html">MappingException</a>
</li>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../../DB/Pool.html">Pool</a>
<ul>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::Pool::TimeoutHelper
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../../DB/Pool/TimeoutHelper.html">DB::Pool::TimeoutHelper</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L176" target="_blank">db/pool.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28timeout%3AFloat64%29-class-method" class="signature"><strong>.new</strong>(timeout : Float64)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#cancel-instance-method" class="signature"><strong>#cancel</strong></a>
</li>
<li class="entry-summary">
<a href="#receive_select_action-instance-method" class="signature"><strong>#receive_select_action</strong></a>
</li>
<li class="entry-summary">
<a href="#start-instance-method" class="signature"><strong>#start</strong></a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;timeout:Float64&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(timeout : Float64)
<a class="method-permalink" href="#new%28timeout%3AFloat64%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L177" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="cancel-instance-method">
<div class="signature">
def <strong>cancel</strong>
<a class="method-permalink" href="#cancel-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L195" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="receive_select_action-instance-method">
<div class="signature">
def <strong>receive_select_action</strong>
<a class="method-permalink" href="#receive_select_action-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L182" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="start-instance-method">
<div class="signature">
def <strong>start</strong>
<a class="method-permalink" href="#start-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool.cr#L186" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,227 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::PoolRetryAttemptsExceeded - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::PoolRetryAttemptsExceeded
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/PoolRetryAttemptsExceeded.html">DB::PoolRetryAttemptsExceeded</a></li><li class="superclass"><a href="../DB/Error.html">DB::Error</a></li><li class="superclass">Exception</li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L11" target="_blank">db/error.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,461 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::PoolStatement - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::PoolStatement
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/PoolStatement.html">DB::PoolStatement</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>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.</p>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/StatementMethods.html">DB::StatementMethods</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L6" target="_blank">db/pool_statement.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28db%3ADatabase%2Cquery%3AString%29-class-method" class="signature"><strong>.new</strong>(db : Database, query : String)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#exec%28args%3AArray%29%3AExecResult-instance-method" class="signature"><strong>#exec</strong>(args : Array) : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec%3AExecResult-instance-method" class="signature"><strong>#exec</strong> : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec%28%2Aargs%29%3AExecResult-instance-method" class="signature"><strong>#exec</strong>(*args) : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28args%3AArray%29%3AResultSet-instance-method" class="signature"><strong>#query</strong>(args : Array) : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%3AResultSet-instance-method" class="signature"><strong>#query</strong> : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28%2Aargs%29%3AResultSet-instance-method" class="signature"><strong>#query</strong>(*args) : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/StatementMethods.html">DB::StatementMethods</a></code></h3>
<a href="../DB/StatementMethods.html#exec%28args%3AArray%29%3AExecResult-instance-method" class="tooltip">
<span>exec(args : Array) : ExecResult<br/>exec : ExecResult<br/>exec(*args) : ExecResult</span>
exec</a>,
<a href="../DB/StatementMethods.html#query%28%2Aargs%2C%26block%29-instance-method" class="tooltip">
<span>query(*args, &block)<br/>query(args : Array) : ResultSet<br/>query : ResultSet<br/>query(*args) : ResultSet</span>
query</a>,
<a href="../DB/StatementMethods.html#scalar%28%2Aargs%29-instance-method" class="tooltip">
<span>scalar(*args)</span>
scalar</a>
<h3>Instance methods inherited from module <code><a href="../DB/Disposable.html">DB::Disposable</a></code></h3>
<a href="../DB/Disposable.html#close-instance-method" class="tooltip">
<span>close</span>
close</a>,
<a href="../DB/Disposable.html#closed%3F-instance-method" class="tooltip">
<span>closed?</span>
closed?</a>
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;db:Database,query:String&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(db : <a href="../DB/Database.html">Database</a>, query : String)
<a class="method-permalink" href="#new%28db%3ADatabase%2Cquery%3AString%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L12" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="exec&#40;args:Array&#41;:ExecResult-instance-method">
<div class="signature">
def <strong>exec</strong>(args : Array) : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%28args%3AArray%29%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L42" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec:ExecResult-instance-method">
<div class="signature">
def <strong>exec</strong> : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L32" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec&#40;*args&#41;:ExecResult-instance-method">
<div class="signature">
def <strong>exec</strong>(*args) : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%28%2Aargs%29%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L37" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;args:Array&#41;:ResultSet-instance-method">
<div class="signature">
def <strong>query</strong>(args : Array) : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%28args%3AArray%29%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L57" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query:ResultSet-instance-method">
<div class="signature">
def <strong>query</strong> : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L47" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;*args&#41;:ResultSet-instance-method">
<div class="signature">
def <strong>query</strong>(*args) : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%28%2Aargs%29%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/pool_statement.cr#L52" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,227 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::PoolTimeout - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::PoolTimeout
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/PoolTimeout.html">DB::PoolTimeout</a></li><li class="superclass"><a href="../DB/Error.html">DB::Error</a></li><li class="superclass">Exception</li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/error.cr#L8" target="_blank">db/error.cr</a>
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,626 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::QueryMethods - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">module</span> DB::QueryMethods
</h1>
<h2>Overview</h2>
<p>Methods to allow querying a database.
All methods accepts a <code>query : String</code> and a set arguments.</p>
<p>Three kind of statements can be performed:</p>
<ol><li><code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">#exec</a></code> waits no record response from the database. An <code><a href="../DB/ExecResult.html">ExecResult</a></code> is returned.</li><li><code><a href="../DB/QueryMethods.html#scalar%28query%2C%2Aargs%29-instance-method">#scalar</a></code> reads a single value of the response. A union of possible values is returned.</li><li><code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">#query</a></code> returns a <code><a href="../DB/ResultSet.html">ResultSet</a></code> that allows iteration over the rows in the response and column information.</li></ol>
<p>Arguments can be passed by position</p>
<pre><code>db.query(<span class="s">&quot;SELECT name FROM ... WHERE age &gt; ?&quot;</span>, age)</code></pre>
<p>Convention of mapping how arguments are mapped to the query depends on each driver.</p>
<p>Including <code><a href="../DB/QueryMethods.html">QueryMethods</a></code> requires a <code>prepare(query) : <a href="../DB/Statement.html">Statement</a></code> method that is not expected
to be called directly.</p>
<h2>Direct including types</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/Connection.html">DB::Connection</a></li>
<li class="other-type"><a href="../DB/Database.html">DB::Database</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L20" target="_blank">db/query_methods.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#exec%28query%2C%2Aargs%29-instance-method" class="signature"><strong>#exec</strong>(query, *args)</a>
<div class="summary"><p>Performs the <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">#query</a></code> and returns an <code><a href="../DB/ExecResult.html">ExecResult</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28query%2C%2Aargs%29-instance-method" class="signature"><strong>#query</strong>(query, *args)</a>
<div class="summary"><p>Executes a <em>query</em> and returns a <code><a href="../DB/ResultSet.html">ResultSet</a></code> with the results.</p></div>
</li>
<li class="entry-summary">
<a href="#query%28query%2C%2Aargs%2C%26block%29-instance-method" class="signature"><strong>#query</strong>(query, *args, &block)</a>
<div class="summary"><p>Executes a <em>query</em> and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code> with the results.</p></div>
</li>
<li class="entry-summary">
<a href="#query_all%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AArray%28U%29-instance-method" class="signature"><strong>#query_all</strong>(query, *args, &block : ResultSet -> U) : Array(U)</a>
<div class="summary"><p>Executes a <em>query</em> and yield a <code><a href="../DB/ResultSet.html">ResultSet</a></code> positioned at the beginning of each row, returning an array of the values of the blocks.</p></div>
</li>
<li class="entry-summary">
<a href="#query_all%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method" class="signature"><strong>#query_all</strong>(query, *args, as types : Tuple)</a>
<div class="summary"><p>Executes a <em>query</em> and returns an array where each row is read as a tuple of the given <em>types</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#query_all%28query%2C%2Aargs%2Castype%3AClass%29-instance-method" class="signature"><strong>#query_all</strong>(query, *args, as type : Class)</a>
<div class="summary"><p>Executes a <em>query</em> and returns an array where there first column's value of each row is read as the given <em>type</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU-instance-method" class="signature"><strong>#query_one</strong>(query, *args, &block : ResultSet -> U) : U</a>
<div class="summary"><p>Executes a <em>query</em> that expects a single row and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code> positioned at that first row.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method" class="signature"><strong>#query_one</strong>(query, *args, as types : Tuple)</a>
<div class="summary"><p>Executes a <em>query</em> that expects a single row and returns it as a tuple of the given <em>types</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%28query%2C%2Aargs%2Castype%3AClass%29-instance-method" class="signature"><strong>#query_one</strong>(query, *args, as type : Class)</a>
<div class="summary"><p>Executes a <em>query</em> that expects a single row and returns the first column's value as the given <em>type</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%3F%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU%3F-instance-method" class="signature"><strong>#query_one?</strong>(query, *args, &block : ResultSet -> U) : U?</a>
<div class="summary"><p>Executes a <em>query</em> that expects at most a single row and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code> positioned at that first row.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%3F%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method" class="signature"><strong>#query_one?</strong>(query, *args, as types : Tuple)</a>
<div class="summary"><p>Executes a <em>query</em> that expects a single row and returns it as a tuple of the given <em>types</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#query_one%3F%28query%2C%2Aargs%2Castype%3AClass%29-instance-method" class="signature"><strong>#query_one?</strong>(query, *args, as type : Class)</a>
<div class="summary"><p>Executes a <em>query</em> that expects a single row and returns the first column's value as the given <em>type</em>.</p></div>
</li>
<li class="entry-summary">
<a href="#scalar%28query%2C%2Aargs%29-instance-method" class="signature"><strong>#scalar</strong>(query, *args)</a>
<div class="summary"><p>Performs the <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">#query</a></code> and returns a single scalar value puts db.scalar("SELECT MAX(name)").as(String) # => (a String)</p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="exec&#40;query,*args&#41;-instance-method">
<div class="signature">
def <strong>exec</strong>(query, *args)
<a class="method-permalink" href="#exec%28query%2C%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>Performs the <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">#query</a></code> and returns an <code><a href="../DB/ExecResult.html">ExecResult</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L202" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;query,*args&#41;-instance-method">
<div class="signature">
def <strong>query</strong>(query, *args)
<a class="method-permalink" href="#query%28query%2C%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> and returns a <code><a href="../DB/ResultSet.html">ResultSet</a></code> with the results.
The <code><a href="../DB/ResultSet.html">ResultSet</a></code> must be closed manually.</p>
<pre><code>result <span class="o">=</span> db.query <span class="s">&quot;select name from contacts where id &#61; ?&quot;</span>, <span class="n">10</span>
<span class="k">begin</span>
<span class="k">if</span> result.move_next
id <span class="o">=</span> result.read(<span class="t">Int32</span>)
<span class="k">end</span>
<span class="k">ensure</span>
result.close
<span class="k">end</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L37" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;query,*args,&amp;block&#41;-instance-method">
<div class="signature">
def <strong>query</strong>(query, *args, &block)
<a class="method-permalink" href="#query%28query%2C%2Aargs%2C%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code> with the results.
The <code><a href="../DB/ResultSet.html">ResultSet</a></code> is closed automatically.</p>
<pre><code>db.query(<span class="s">&quot;select name from contacts where age &gt; ?&quot;</span>, <span class="n">18</span>) <span class="k">do</span> <span class="o">|</span>rs<span class="o">|</span>
rs.each <span class="k">do</span>
name <span class="o">=</span> rs.read(<span class="t">String</span>)
<span class="k">end</span>
<span class="k">end</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L51" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_all&#40;query,*args,&amp;block:ResultSet-&gt;U&#41;:Array&#40;U&#41;-instance-method">
<div class="signature">
def <strong>query_all</strong>(query, *args, &block : <a href="../DB/ResultSet.html">ResultSet</a> -> U) : Array(U)
<a class="method-permalink" href="#query_all%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AArray%28U%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> and yield a <code><a href="../DB/ResultSet.html">ResultSet</a></code> positioned at the beginning
of each row, returning an array of the values of the blocks.</p>
<pre><code>names <span class="o">=</span> db.query_all <span class="s">&quot;select name from contacts&quot;</span>, <span class="o">&</span>.read(<span class="t">String</span>)</code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L167" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_all&#40;query,*args,astypes:Tuple&#41;-instance-method">
<div class="signature">
def <strong>query_all</strong>(query, *args, as types : Tuple)
<a class="method-permalink" href="#query_all%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> and returns an array where each row is
read as a tuple of the given <em>types</em>.</p>
<pre><code>contacts <span class="o">=</span> db.query_all <span class="s">&quot;select name, age from contactas&quot;</span>, <span class="k">as</span>: {<span class="t">String</span>, <span class="t">Int32</span>}</code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L183" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_all&#40;query,*args,astype:Class&#41;-instance-method">
<div class="signature">
def <strong>query_all</strong>(query, *args, as type : Class)
<a class="method-permalink" href="#query_all%28query%2C%2Aargs%2Castype%3AClass%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> and returns an array where there first
column's value of each row is read as the given <em>type</em>.</p>
<pre><code>names <span class="o">=</span> db.query_all <span class="s">&quot;select name from contactas&quot;</span>, <span class="k">as</span>: <span class="t">String</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L195" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one&#40;query,*args,&amp;block:ResultSet-&gt;U&#41;:U-instance-method">
<div class="signature">
def <strong>query_one</strong>(query, *args, &block : <a href="../DB/ResultSet.html">ResultSet</a> -> U) : U
<a class="method-permalink" href="#query_one%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects a single row and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code>
positioned at that first row.</p>
<p>The given block must not invoke <code>move_next</code> on the yielded result set.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were no rows, or if there were more than one row.</p>
<pre><code>name <span class="o">=</span> db.query_one <span class="s">&quot;select name from contacts where id &#61; ?&quot;</span>, <span class="n">18</span>, <span class="o">&</span>.read(<span class="t">String</span>)</code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L67" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one&#40;query,*args,astypes:Tuple&#41;-instance-method">
<div class="signature">
def <strong>query_one</strong>(query, *args, as types : Tuple)
<a class="method-permalink" href="#query_one%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects a single row and returns it
as a tuple of the given <em>types</em>.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were no rows, or if there were more than one row.</p>
<pre><code>db.query_one <span class="s">&quot;select name, age from contacts where id &#61; ?&quot;</span>, <span class="n">1</span>, <span class="k">as</span>: {<span class="t">String</span>, <span class="t">Int32</span>}</code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L85" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one&#40;query,*args,astype:Class&#41;-instance-method">
<div class="signature">
def <strong>query_one</strong>(query, *args, as type : Class)
<a class="method-permalink" href="#query_one%28query%2C%2Aargs%2Castype%3AClass%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects a single row
and returns the first column's value as the given <em>type</em>.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were no rows, or if there were more than one row.</p>
<pre><code>db.query_one <span class="s">&quot;select name from contacts where id &#61; ?&quot;</span>, <span class="n">1</span>, <span class="k">as</span>: <span class="t">String</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L99" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one?&#40;query,*args,&amp;block:ResultSet-&gt;U&#41;:U?-instance-method">
<div class="signature">
def <strong>query_one?</strong>(query, *args, &block : <a href="../DB/ResultSet.html">ResultSet</a> -> U) : U?
<a class="method-permalink" href="#query_one%3F%28query%2C%2Aargs%2C%26block%3AResultSet-%3EU%29%3AU%3F-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects at most a single row and yields a <code><a href="../DB/ResultSet.html">ResultSet</a></code>
positioned at that first row.</p>
<p>Returns <code>nil</code>, not invoking the block, if there were no rows.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were more than one row
(this ends up invoking the block once).</p>
<pre><code>name <span class="o">=</span> db.query_one? <span class="s">&quot;select name from contacts where id &#61; ?&quot;</span>, <span class="n">18</span>, <span class="o">&</span>.read(<span class="t">String</span>)
<span class="k">typeof</span>(name) <span class="c"># &#61;&gt; String | Nil</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L117" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one?&#40;query,*args,astypes:Tuple&#41;-instance-method">
<div class="signature">
def <strong>query_one?</strong>(query, *args, as types : Tuple)
<a class="method-permalink" href="#query_one%3F%28query%2C%2Aargs%2Castypes%3ATuple%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects a single row and returns it
as a tuple of the given <em>types</em>.</p>
<p>Returns <code>nil</code> if there were no rows.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were more than one row.</p>
<pre><code>result <span class="o">=</span> db.query_one? <span class="s">&quot;select name, age from contacts where id &#61; ?&quot;</span>, <span class="n">1</span>, <span class="k">as</span>: {<span class="t">String</span>, <span class="t">Int32</span>}
<span class="k">typeof</span>(result) <span class="c"># &#61;&gt; Tuple&#40;String, Int32&#41; | Nil</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L138" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query_one?&#40;query,*args,astype:Class&#41;-instance-method">
<div class="signature">
def <strong>query_one?</strong>(query, *args, as type : Class)
<a class="method-permalink" href="#query_one%3F%28query%2C%2Aargs%2Castype%3AClass%29-instance-method">#</a>
</div>
<div class="doc"><p>Executes a <em>query</em> that expects a single row
and returns the first column's value as the given <em>type</em>.</p>
<p>Returns <code>nil</code> if there were no rows.</p>
<p>Raises <code><a href="../DB/Error.html">DB::Error</a></code> if there were more than one row.</p>
<pre><code>name <span class="o">=</span> db.query_one? <span class="s">&quot;select name from contacts where id &#61; ?&quot;</span>, <span class="n">1</span>, <span class="k">as</span>: <span class="t">String</span>
<span class="k">typeof</span>(name) <span class="c"># &#61;&gt; String?</span></code></pre></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L155" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="scalar&#40;query,*args&#41;-instance-method">
<div class="signature">
def <strong>scalar</strong>(query, *args)
<a class="method-permalink" href="#scalar%28query%2C%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>Performs the <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">#query</a></code> and returns a single scalar value
puts db.scalar("SELECT MAX(name)").as(String) # => (a String)</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/query_methods.cr#L208" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

550
api/0.2.2/DB/ResultSet.html Normal file
View file

@ -0,0 +1,550 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::ResultSet - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">abstract class</span> DB::ResultSet
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/ResultSet.html">DB::ResultSet</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>The response of a query performed on a <code><a href="../DB/Database.html">Database</a></code>.</p>
<p>See <code><a href="../DB.html">DB</a></code> for a complete sample.</p>
<p>Each <code><a href="../DB/ResultSet.html#read-instance-method">#read</a></code> call consumes the result and moves to the next column.
Each column must be read in order.
At any moment a <code><a href="../DB/ResultSet.html#move_next%3ABool-instance-method">#move_next</a></code> 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 <code><a href="../DB/ResultSet.html">ResultSet</a></code>, hence an iteration
through <code><a href="../DB/ResultSet.html#each%28%26block%29-instance-method">#each</a></code> or <code><a href="../DB/ResultSet.html#move_next%3ABool-instance-method">#move_next</a></code> can be stopped.</p>
<p><strong>Note:</strong> depending on how the <code><a href="../DB/ResultSet.html">ResultSet</a></code> was obtained it might be mandatory an
explicit call to <code>#close</code>. Check <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code>.</p>
<h3>Note to implementors</h3>
<ol><li>Override <code><a href="../DB/ResultSet.html#move_next%3ABool-instance-method">#move_next</a></code> to move to the next row.</li><li>Override <code><a href="../DB/ResultSet.html#read-instance-method">#read</a></code> returning the next value in the row.</li><li>(Optional) Override <code><a href="../DB/ResultSet.html#read%28type%3ADB%3A%3AMappable.class%29-instance-method">#read(t)</a></code> for some types <code>t</code> for which custom logic other than a simple cast is needed.</li><li>Override <code><a href="../DB/ResultSet.html#column_count%3AInt32-instance-method">#column_count</a></code>, <code><a href="../DB/ResultSet.html#column_name%28index%3AInt32%29%3AString-instance-method">#column_name</a></code>.</li></ol>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/Disposable.html">DB::Disposable</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L22" target="_blank">db/result_set.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28statement%3ADB%3A%3AStatement%29-class-method" class="signature"><strong>.new</strong>(statement : DB::Statement)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#column_count%3AInt32-instance-method" class="signature"><strong>#column_count</strong> : Int32</a>
<div class="summary"><p>Returns the number of columns in the result</p></div>
</li>
<li class="entry-summary">
<a href="#column_name%28index%3AInt32%29%3AString-instance-method" class="signature"><strong>#column_name</strong>(index : Int32) : String</a>
<div class="summary"><p>Returns the name of the column in <code>index</code> 0-based position.</p></div>
</li>
<li class="entry-summary">
<a href="#column_names-instance-method" class="signature"><strong>#column_names</strong></a>
<div class="summary"><p>Returns the name of the columns.</p></div>
</li>
<li class="entry-summary">
<a href="#each%28%26block%29-instance-method" class="signature"><strong>#each</strong>(&block)</a>
<div class="summary"><p>Iterates over all the rows</p></div>
</li>
<li class="entry-summary">
<a href="#each_column%28%26block%29-instance-method" class="signature"><strong>#each_column</strong>(&block)</a>
<div class="summary"><p>Iterates over all the columns</p></div>
</li>
<li class="entry-summary">
<a href="#move_next%3ABool-instance-method" class="signature"><strong>#move_next</strong> : Bool</a>
<div class="summary"><p>Move the next row in the result.</p></div>
</li>
<li class="entry-summary">
<a href="#read%28type%3ADB%3A%3AMappable.class%29-instance-method" class="signature"><strong>#read</strong>(type : DB::Mappable.class)</a>
<div class="summary"><p>Reads the next columns and maps them to a class</p></div>
</li>
<li class="entry-summary">
<a href="#read%28type%3AT.class%29%3ATforallT-instance-method" class="signature"><strong>#read</strong>(type : T.class) : T forall T</a>
<div class="summary"><p>Reads the next column value as a <strong>type</strong></p></div>
</li>
<li class="entry-summary">
<a href="#read-instance-method" class="signature"><strong>#read</strong></a>
<div class="summary"><p>Reads the next column value</p></div>
</li>
<li class="entry-summary">
<a href="#read%28%2Atypes%3AClass%29-instance-method" class="signature"><strong>#read</strong>(*types : Class)</a>
<div class="summary"><p>Reads the next columns and returns a tuple of the values.</p></div>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/Disposable.html">DB::Disposable</a></code></h3>
<a href="../DB/Disposable.html#close-instance-method" class="tooltip">
<span>close</span>
close</a>,
<a href="../DB/Disposable.html#closed%3F-instance-method" class="tooltip">
<span>closed?</span>
closed?</a>
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;statement:DB::Statement&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(statement : <a href="../DB/Statement.html">DB::Statement</a>)
<a class="method-permalink" href="#new%28statement%3ADB%3A%3AStatement%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L28" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="column_count:Int32-instance-method">
<div class="signature">
abstract
def <strong>column_count</strong> : Int32
<a class="method-permalink" href="#column_count%3AInt32-instance-method">#</a>
</div>
<div class="doc"><p>Returns the number of columns in the result</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L59" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="column_name&#40;index:Int32&#41;:String-instance-method">
<div class="signature">
abstract
def <strong>column_name</strong>(index : Int32) : String
<a class="method-permalink" href="#column_name%28index%3AInt32%29%3AString-instance-method">#</a>
</div>
<div class="doc"><p>Returns the name of the column in <code>index</code> 0-based position.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L62" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="column_names-instance-method">
<div class="signature">
def <strong>column_names</strong>
<a class="method-permalink" href="#column_names-instance-method">#</a>
</div>
<div class="doc"><p>Returns the name of the columns.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L65" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="each&#40;&amp;block&#41;-instance-method">
<div class="signature">
def <strong>each</strong>(&block)
<a class="method-permalink" href="#each%28%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>Iterates over all the rows</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L38" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="each_column&#40;&amp;block&#41;-instance-method">
<div class="signature">
def <strong>each_column</strong>(&block)
<a class="method-permalink" href="#each_column%28%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>Iterates over all the columns</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L45" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="move_next:Bool-instance-method">
<div class="signature">
abstract
def <strong>move_next</strong> : Bool
<a class="method-permalink" href="#move_next%3ABool-instance-method">#</a>
</div>
<div class="doc"><p>Move the next row in the result.
Return <code>false</code> if no more rows are available.
See <code><a href="../DB/ResultSet.html#each%28%26block%29-instance-method">#each</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L54" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="read&#40;type:DB::Mappable.class&#41;-instance-method">
<div class="signature">
def <strong>read</strong>(type : DB::Mappable.class)
<a class="method-permalink" href="#read%28type%3ADB%3A%3AMappable.class%29-instance-method">#</a>
</div>
<div class="doc"><p>Reads the next columns and maps them to a class</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L73" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="read&#40;type:T.class&#41;:TforallT-instance-method">
<div class="signature">
def <strong>read</strong>(type : T.class) : T forall T
<a class="method-permalink" href="#read%28type%3AT.class%29%3ATforallT-instance-method">#</a>
</div>
<div class="doc"><p>Reads the next column value as a <strong>type</strong></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L78" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="read-instance-method">
<div class="signature">
abstract
def <strong>read</strong>
<a class="method-permalink" href="#read-instance-method">#</a>
</div>
<div class="doc"><p>Reads the next column value</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L70" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="read&#40;*types:Class&#41;-instance-method">
<div class="signature">
def <strong>read</strong>(*types : Class)
<a class="method-permalink" href="#read%28%2Atypes%3AClass%29-instance-method">#</a>
</div>
<div class="doc"><p>Reads the next columns and returns a tuple of the values.</p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/result_set.cr#L83" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

484
api/0.2.2/DB/Statement.html Normal file
View file

@ -0,0 +1,484 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::Statement - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">abstract class</span> DB::Statement
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/Statement.html">DB::Statement</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Overview</h2>
<p>Represents a prepared query in a <code><a href="../DB/Connection.html">Connection</a></code>.
It should be created by <code><a href="../DB/QueryMethods.html">QueryMethods</a></code>.</p>
<h3>Note to implementors</h3>
<ol><li>Subclass <code>Statements</code></li><li><code>Statements</code> are created from a custom driver <code>Connection#prepare</code> method.</li><li><code>#perform_query</code> executes a query that is expected to return a <code><a href="../DB/ResultSet.html">ResultSet</a></code></li><li><code>#perform_exec</code> executes a query that is expected to return an <code><a href="../DB/ExecResult.html">ExecResult</a></code></li><li><code>#do_close</code> is called to release the statement resources.</li></ol>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/StatementMethods.html">DB::StatementMethods</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L52" target="_blank">db/statement.cr</a>
<br/>
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28connection%3AConnection%29-class-method" class="signature"><strong>.new</strong>(connection : Connection)</a>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#exec%28args%3AArray%29-instance-method" class="signature"><strong>#exec</strong>(args : Array)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec-instance-method" class="signature"><strong>#exec</strong></a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec%28%2Aargs%29-instance-method" class="signature"><strong>#exec</strong>(*args)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28args%3AArray%29-instance-method" class="signature"><strong>#query</strong>(args : Array)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query-instance-method" class="signature"><strong>#query</strong></a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28%2Aargs%29-instance-method" class="signature"><strong>#query</strong>(*args)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#release_connection-instance-method" class="signature"><strong>#release_connection</strong></a>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/StatementMethods.html">DB::StatementMethods</a></code></h3>
<a href="../DB/StatementMethods.html#exec%28args%3AArray%29%3AExecResult-instance-method" class="tooltip">
<span>exec(args : Array) : ExecResult<br/>exec : ExecResult<br/>exec(*args) : ExecResult</span>
exec</a>,
<a href="../DB/StatementMethods.html#query%28%2Aargs%2C%26block%29-instance-method" class="tooltip">
<span>query(*args, &block)<br/>query(args : Array) : ResultSet<br/>query : ResultSet<br/>query(*args) : ResultSet</span>
query</a>,
<a href="../DB/StatementMethods.html#scalar%28%2Aargs%29-instance-method" class="tooltip">
<span>scalar(*args)</span>
scalar</a>
<h3>Instance methods inherited from module <code><a href="../DB/Disposable.html">DB::Disposable</a></code></h3>
<a href="../DB/Disposable.html#close-instance-method" class="tooltip">
<span>close</span>
close</a>,
<a href="../DB/Disposable.html#closed%3F-instance-method" class="tooltip">
<span>closed?</span>
closed?</a>
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="new&#40;connection:Connection&#41;-class-method">
<div class="signature">
def self.<strong>new</strong>(connection : <a href="../DB/Connection.html">Connection</a>)
<a class="method-permalink" href="#new%28connection%3AConnection%29-class-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L58" target="_blank">View source</a>]
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="exec&#40;args:Array&#41;-instance-method">
<div class="signature">
def <strong>exec</strong>(args : Array)
<a class="method-permalink" href="#exec%28args%3AArray%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L71" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec-instance-method">
<div class="signature">
def <strong>exec</strong>
<a class="method-permalink" href="#exec-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L66" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec&#40;*args&#41;-instance-method">
<div class="signature">
def <strong>exec</strong>(*args)
<a class="method-permalink" href="#exec%28%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L76" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;args:Array&#41;-instance-method">
<div class="signature">
def <strong>query</strong>(args : Array)
<a class="method-permalink" href="#query%28args%3AArray%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L87" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query-instance-method">
<div class="signature">
def <strong>query</strong>
<a class="method-permalink" href="#query-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L82" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;*args&#41;-instance-method">
<div class="signature">
def <strong>query</strong>(*args)
<a class="method-permalink" href="#query%28%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L92" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="release_connection-instance-method">
<div class="signature">
def <strong>release_connection</strong>
<a class="method-permalink" href="#release_connection-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L61" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,447 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::StatementMethods - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">module</span> DB::StatementMethods
</h1>
<h2>Overview</h2>
<p>Common interface for connection based statements
and for connection pool statements.</p>
<h2>Included Modules</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/Disposable.html">DB::Disposable</a></li>
</ul>
<h2>Direct including types</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../DB/PoolStatement.html">DB::PoolStatement</a></li>
<li class="other-type"><a href="../DB/Statement.html">DB::Statement</a></li>
</ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L4" target="_blank">db/statement.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#exec%28args%3AArray%29%3AExecResult-instance-method" class="signature"><strong>#exec</strong>(args : Array) : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec%3AExecResult-instance-method" class="signature"><strong>#exec</strong> : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#exec%28%2Aargs%29%3AExecResult-instance-method" class="signature"><strong>#exec</strong>(*args) : ExecResult</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28%2Aargs%2C%26block%29-instance-method" class="signature"><strong>#query</strong>(*args, &block)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28args%3AArray%29%3AResultSet-instance-method" class="signature"><strong>#query</strong>(args : Array) : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%3AResultSet-instance-method" class="signature"><strong>#query</strong> : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#query%28%2Aargs%29%3AResultSet-instance-method" class="signature"><strong>#query</strong>(*args) : ResultSet</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#scalar%28%2Aargs%29-instance-method" class="signature"><strong>#scalar</strong>(*args)</a>
<div class="summary"><p>See <code><a href="../DB/QueryMethods.html#scalar%28query%2C%2Aargs%29-instance-method">QueryMethods#scalar</a></code></p></div>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from module <code><a href="../DB/Disposable.html">DB::Disposable</a></code></h3>
<a href="../DB/Disposable.html#close-instance-method" class="tooltip">
<span>close</span>
close</a>,
<a href="../DB/Disposable.html#closed%3F-instance-method" class="tooltip">
<span>closed?</span>
closed?</a>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="exec&#40;args:Array&#41;:ExecResult-instance-method">
<div class="signature">
abstract
def <strong>exec</strong>(args : Array) : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%28args%3AArray%29%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L32" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec:ExecResult-instance-method">
<div class="signature">
abstract
def <strong>exec</strong> : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L28" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="exec&#40;*args&#41;:ExecResult-instance-method">
<div class="signature">
abstract
def <strong>exec</strong>(*args) : <a href="../DB/ExecResult.html">ExecResult</a>
<a class="method-permalink" href="#exec%28%2Aargs%29%3AExecResult-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#exec%28query%2C%2Aargs%29-instance-method">QueryMethods#exec</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L30" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;*args,&amp;block&#41;-instance-method">
<div class="signature">
def <strong>query</strong>(*args, &block)
<a class="method-permalink" href="#query%28%2Aargs%2C%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L22" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;args:Array&#41;:ResultSet-instance-method">
<div class="signature">
abstract
def <strong>query</strong>(args : Array) : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%28args%3AArray%29%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L39" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query:ResultSet-instance-method">
<div class="signature">
abstract
def <strong>query</strong> : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L35" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="query&#40;*args&#41;:ResultSet-instance-method">
<div class="signature">
abstract
def <strong>query</strong>(*args) : <a href="../DB/ResultSet.html">ResultSet</a>
<a class="method-permalink" href="#query%28%2Aargs%29%3AResultSet-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#query%28query%2C%2Aargs%29-instance-method">QueryMethods#query</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L37" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="scalar&#40;*args&#41;-instance-method">
<div class="signature">
def <strong>scalar</strong>(*args)
<a class="method-permalink" href="#scalar%28%2Aargs%29-instance-method">#</a>
</div>
<div class="doc"><p>See <code><a href="../DB/QueryMethods.html#scalar%28query%2C%2Aargs%29-instance-method">QueryMethods#scalar</a></code></p></div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/statement.cr#L11" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,284 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<title>DB::StringKeyCache(T) - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li><a href="../index.html">README</a></li>
</ul>
<ul>
<li class="parent open current" data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="../DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="../DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="../DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="../DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="../DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="../DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="../DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="../DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="../DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="../DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="../DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="../DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="../DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="../DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="../DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="../DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="../DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="../DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="../DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="../DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" current" data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="../DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1 class="type-name">
<span class="kind">class</span> DB::StringKeyCache(T)
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../DB/StringKeyCache.html">DB::StringKeyCache(T)</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>Defined in:</h2>
<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/string_key_cache.cr#L2" target="_blank">db/string_key_cache.cr</a>
<br/>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#clear-instance-method" class="signature"><strong>#clear</strong></a>
</li>
<li class="entry-summary">
<a href="#each_value%28%26block%29-instance-method" class="signature"><strong>#each_value</strong>(&block)</a>
</li>
<li class="entry-summary">
<a href="#fetch%28key%3AString%2C%26block%29%3AT-instance-method" class="signature"><strong>#fetch</strong>(key : String, &block) : T</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="clear-instance-method">
<div class="signature">
def <strong>clear</strong>
<a class="method-permalink" href="#clear-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/string_key_cache.cr#L17" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="each_value&#40;&amp;block&#41;-instance-method">
<div class="signature">
def <strong>each_value</strong>(&block)
<a class="method-permalink" href="#each_value%28%26block%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/string_key_cache.cr#L11" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="fetch&#40;key:String,&amp;block&#41;:T-instance-method">
<div class="signature">
def <strong>fetch</strong>(key : String, &block) : T
<a class="method-permalink" href="#fetch%28key%3AString%2C%26block%29%3AT-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-lang/crystal-db/blob/73108c169ec87d229c7b92d793748d9796d20802/src/db/string_key_cache.cr#L5" target="_blank">View source</a>]
</div>
</div>
</div>
</body>
</html>

432
api/0.2.2/css/style.css Normal file
View file

@ -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;
}

205
api/0.2.2/index.html Normal file
View file

@ -0,0 +1,205 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/crystal-lang/crystal-db">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<title>README - github.com/crystal-lang/crystal-db</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li class="current"><a href="index.html">README</a></li>
</ul>
<ul>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB" data-name="db">
<a href="DB.html">DB</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Any" data-name="db::any">
<a href="DB/Any.html">Any</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Connection" data-name="db::connection">
<a href="DB/Connection.html">Connection</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ConnectionLost" data-name="db::connectionlost">
<a href="DB/ConnectionLost.html">ConnectionLost</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Database" data-name="db::database">
<a href="DB/Database.html">Database</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Disposable" data-name="db::disposable">
<a href="DB/Disposable.html">Disposable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Driver" data-name="db::driver">
<a href="DB/Driver.html">Driver</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Error" data-name="db::error">
<a href="DB/Error.html">Error</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ExecResult" data-name="db::execresult">
<a href="DB/ExecResult.html">ExecResult</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Mappable" data-name="db::mappable">
<a href="DB/Mappable.html">Mappable</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/MappingException" data-name="db::mappingexception">
<a href="DB/MappingException.html">MappingException</a>
</li>
<li class="parent " data-id="github.com/crystal-lang/crystal-db/DB/Pool" data-name="db::pool(t)">
<a href="DB/Pool.html">Pool</a>
<ul>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper" data-name="db::pool::timeouthelper">
<a href="DB/Pool/TimeoutHelper.html">TimeoutHelper</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded" data-name="db::poolretryattemptsexceeded">
<a href="DB/PoolRetryAttemptsExceeded.html">PoolRetryAttemptsExceeded</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolStatement" data-name="db::poolstatement">
<a href="DB/PoolStatement.html">PoolStatement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/PoolTimeout" data-name="db::pooltimeout">
<a href="DB/PoolTimeout.html">PoolTimeout</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/QueryMethods" data-name="db::querymethods">
<a href="DB/QueryMethods.html">QueryMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/ResultSet" data-name="db::resultset">
<a href="DB/ResultSet.html">ResultSet</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/Statement" data-name="db::statement">
<a href="DB/Statement.html">Statement</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StatementMethods" data-name="db::statementmethods">
<a href="DB/StatementMethods.html">StatementMethods</a>
</li>
<li class=" " data-id="github.com/crystal-lang/crystal-db/DB/StringKeyCache" data-name="db::stringkeycache(t)">
<a href="DB/StringKeyCache.html">StringKeyCache</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<p><a href="https://travis-ci.org/crystal-lang/crystal-db" target="_blank"><img src="https://travis-ci.org/crystal-lang/crystal-db.svg?branch=master" alt="Build Status"/></a></p>
<h1>crystal-db</h1>
<p>Common db api for crystal. You will need to a specific driver to access a database.</p>
<ul><li><a href="https://github.com/crystal-lang/crystal-sqlite3" target="_blank">sqlite</a></li><li><a href="https://github.com/crystal-lang/crystal-mysql" target="_blank">mysql</a></li></ul>
<h2>Installation</h2>
<p>Add this to your application's <code>shard.yml</code>:</p>
<pre><code class='language-yaml'>dependencies:
db:
github: crystal-lang/crystal-db</code></pre>
<h2>Usage</h2>
<p>Since this is an abstract db api, it's usage is through a concrete database driver.</p>
<pre><code class='language-crystal'><span class="k">require</span> <span class="s">&quot;db&quot;</span>
<span class="k">require</span> <span class="s">&quot;sqlite3&quot;</span>
<span class="t">DB</span>.open <span class="s">&quot;sqlite3:./file.db&quot;</span> <span class="k">do</span> <span class="o">|</span>db<span class="o">|</span>
db.exec <span class="s">&quot;create table contacts &#40;name string, age integer&#41;&quot;</span>
db.exec <span class="s">&quot;insert into contacts values &#40;?, ?&#41;&quot;</span>, <span class="s">&quot;John Doe&quot;</span>, <span class="n">30</span>
args <span class="o">=</span> <span class="o">[]</span> <span class="k">of</span> <span class="t">DB</span><span class="t">::</span><span class="t">Any</span>
args <span class="o"><<</span> <span class="s">&quot;Sarah&quot;</span>
args <span class="o"><<</span> <span class="n">33</span>
db.exec <span class="s">&quot;insert into contacts values &#40;?, ?&#41;&quot;</span>, args
puts <span class="s">&quot;max age:&quot;</span>
puts db.scalar <span class="s">&quot;select max&#40;age&#41; from contacts&quot;</span> <span class="c"># &#61;&gt; 33</span>
puts <span class="s">&quot;contacts:&quot;</span>
db.query <span class="s">&quot;select name, age from contacts order by age desc&quot;</span> <span class="k">do</span> <span class="o">|</span>rs<span class="o">|</span>
puts <span class="s">&quot;</span><span class="i">#{</span></span>rs.column_name(<span class="n">0</span>)<span class="s"><span class="i">}</span> &#40;</span><span class="i">#{</span></span>rs.column_name(<span class="n">1</span>)<span class="s"><span class="i">}</span>&#41;&quot;</span>
<span class="c"># &#61;&gt; name &#40;age&#41;</span>
rs.each <span class="k">do</span>
puts <span class="s">&quot;</span><span class="i">#{</span></span>rs.read(<span class="t">String</span>)<span class="s"><span class="i">}</span> &#40;</span><span class="i">#{</span></span>rs.read(<span class="t">Int32</span>)<span class="s"><span class="i">}</span>&#41;&quot;</span>
<span class="c"># &#61;&gt; Sarah &#40;33&#41;</span>
<span class="c"># &#61;&gt; John Doe &#40;30&#41;</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span></code></pre>
<h2>Roadmap</h2>
<p>Issues not yet addressed</p>
<ul><li>[ ] Support non prepared statements.</li><li>[ ] Time data type.</li><li>[x] Data type extensibility. Allow each driver to extend the data types allowed.</li><li>[ ] Transactions.</li><li>[ ] Connection pool.</li><li>[ ] Direct access to <code>IO</code> to avoid memory allocation for blobs.</li></ul>
<h2>Contributing</h2>
<ol><li>Fork it ( https://github.com/crystal-lang/crystal-db/fork )</li><li>Create your feature branch (git checkout -b my-new-feature)</li><li>Commit your changes (git commit -am 'Add some feature')</li><li>Push to the branch (git push origin my-new-feature)</li><li>Create a new Pull Request</li></ol>
<h2>Contributors</h2>
<ul><li><a href="https://github.com/bcardiff" target="_blank">bcardiff</a> Brian J. Cardiff - creator, maintainer</li></ul>
</div>
</body>
</html>

108
api/0.2.2/js/doc.js Normal file
View file

@ -0,0 +1,108 @@
document.addEventListener('DOMContentLoaded', function() {
var sessionStorage = window.sessionStorage;
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();
});