This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!DOCTYPE html>
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>InferBase__SqliteUtils (InferBase.InferBase__SqliteUtils)</title><linkrel="stylesheet"href="../../odoc.css"/><metacharset="utf-8"/><metaname="generator"content="odoc %%VERSION%%"/><metaname="viewport"content="width=device-width,initial-scale=1.0"/><scriptsrc="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><divclass="content"><header><nav><ahref="../index.html">Up</a>–<ahref="../index.html">InferBase</a>» InferBase__SqliteUtils</nav><h1>Module <code>InferBase__SqliteUtils</code></h1></header><dl><dtclass="spec exception"id="exception-Error"><ahref="#exception-Error"class="anchor"></a><code><spanclass="keyword">exception</span></code><code><spanclass="exception">Error</span><spanclass="keyword">of</span> string</code></dt><dd><p>The functions in this module tend to raise more often than their counterparts in <code>Sqlite3</code>. In particular, they may raise if the <code>Sqlite3.Rc.t</code> result of certain operations is unexpected.</p></dd></dl><dl><dtclass="spec value"id="val-check_result_code"><ahref="#val-check_result_code"class="anchor"></a><code><spanclass="keyword">val</span> check_result_code : Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.Rc.t <span>-></span> unit</code></dt><dd><p>Assert that the result is either <code>Sqlite3.Rc.OK</code> or <code>Sqlite3.Rc.ROW</code>. If the result is not valid, then if <code>fatal</code> is set raise <ahref="index.html#exception-Error"><code>Error</code></a>, otherwise log the error and proceed.</p></dd></dl><dl><dtclass="spec value"id="val-exec"><ahref="#val-exec"class="anchor"></a><code><spanclass="keyword">val</span> exec : Sqlite3.db <span>-></span><span>log:string</span><span>-></span><span>stmt:string</span><span>-></span> unit</code></dt><dd><p>Execute the given Sqlite <code>stmt</code> and check the result with <code>check_result_code ~fatal:true</code>.</p></dd></dl><dl><dtclass="spec value"id="val-finalize"><ahref="#val-finalize"class="anchor"></a><code><spanclass="keyword">val</span> finalize : Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.stmt <span>-></span> unit</code></dt><dd><p>Finalize the given <code>stmt</code>. Raises <ahref="index.html#exception-Error"><code>Error</code></a> on failure.</p></dd></dl><dl><dtclass="spec value"id="val-result_fold_rows"><ahref="#val-result_fold_rows"class="anchor"></a><code><spanclass="keyword">val</span> result_fold_rows : <span>?⁠finalize:bool</span><span>-></span> Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.stmt <span>-></span><span>init:<spanclass="type-var">'a</span></span><span>-></span><span>f:<span>(<spanclass="type-var">'a</span><span>-></span> Sqlite3.stmt <span>-></span><spanclass="type-var">'a</span>)</span></span><span>-></span><spanclass="type-var">'a</span></code></dt><dd><p>Fold <code>f</code> over each row of the result. <code>f</code> must not access the database.</p></dd></dl><dl><dtclass="spec value"id="val-result_fold_single_column_rows"><ahref="#val-result_fold_single_column_rows"class="anchor"></a><code><spanclass="keyword">val</span> result_fold_single_column_rows : <span>?⁠finalize:bool</span><span>-></span> Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.stmt <span>-></span><span>init:<spanclass="type-var">'b</span></span><span>-></span><span>f:<span>(<spanclass="type-var">'b</span><span>-></span> Sqlite3.Data.t <span>-></span><spanclass="type-var">'b</span>)</span></span><span>-></span><spanclass="type-var">'b</span></code></dt><dd><p>Like <ahref="index.html#val-result_fold_rows"><code>result_fold_rows</code></a> but pass column 0 of each row in the results to <code>f</code>.</p></dd></dl><dl><dtclass="spec value"id="val-result_option"><ahref="#val-result_option"class="anchor"></a><code><spanclass="keyword">val</span> result_option : <span>?⁠finalize:bool</span><span>-></span> Sqlite3.db <span>-></span><span>log:string</span><span>-></span><span>read_row:<span>(Sqlite3.stmt <span>-></span><spanclass="type-var">'a</span>)</span></span><span>-></span> Sqlite3.stmt <span>-></span><span><spanclass="type-var">'a</span> option</span></code></dt><dd><p>Same as <ahref="index.html#val-result_fold_rows"><code>result_fold_rows</code></a> but asserts that at most one row is returned.</p></dd></dl><dl><dtclass="spec value"id="val-result_single_column_option"><ahref="#val-result_single_column_option"class="anchor"></a><code><spanclass="keyword">val</span> result_single_column_option : <span>?⁠finalize:bool</span><span>-></span> Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.stmt <span>-></span><span>Sqlite3.Data.t option</span></code></dt><dd><p>Same as <ahref="index.html#val-result_fold_single_column_rows"><code>result_fold_single_column_rows</code></a> but asserts that at most one row is returned.</p></dd></dl><dl><dtclass="spec value"id="val-result_unit"><ahref="#val-result_unit"class="anchor"></a><code><spanclass="keyword">val</span> result_unit : <span>?⁠finalize:bool</span><span>-></span> Sqlite3.db <span>-></span><span>log:string</span><span>-></span> Sqlite3.stmt <span>-></span> unit</code></dt><dd><p>Same as <ahref="index.html#val-result_fold_rows"><code>result_fold_rows</code></a> but asserts that no row is returned.</p></dd></dl><dl><dtclass="spec value"id="val-db_close"><ahref="#val-db_close"class="anchor"></a><code><spanclass="keyword">val</span> db_close : Sqlite3.db <span>-></span> unit</code></dt><dd><p>Close the given database and asserts that it was effective. Raises <ahref="index.html#exception-Error"><code>Error</code></a> if not.</p></dd></dl><dl><dtclass="spec value"id="val-with_transaction"><ahref="#val-with_transaction"class="anchor"></a><code><spanclass="keyword">val</span> with_transaction : Sqlite3.db <span>-></span><span>f:<span>(unit <span>-></span> unit)</span></span><span>-></span> unit</code></dt><dd><p>Execute <code>f</code> within an explicit sqlite transaction.</p></dd></dl><dl><dtclass="spec module-type"id="module-type-Data"><ahref="#module-type-Data"class="anchor"></a><code><spanclass="keyword">module</span><spanclass="keyword">type</span><ahref="module-type-Data/index.html">Data</a> = <spanclass="keyword">sig</span> ... <spanclass="keyword">end</span></code></dt><dd><p>An API commonly needed to store and retrieve objects from the database</p></dd></dl><dl><dtclass="spec module"id="module-MarshalledDataForComparison"><ahref="#module-MarshalledDataForComparison"class="anchor"></a><code><spanclass="keyword">module</span><ahref="MarshalledDataForComparison/index.html">MarshalledDataForComparison</a> : <spanclass="keyword">functor</span> (<ahref="MarshalledDataForComparison/argument-1-D/index.html">D</a> : <spanclass="keyword">sig</span> ... <spanclass="keyword">end</span>) <span>-></span><ahref="index.html#module-type-Data">Data</a><spanclass="keyword">with</span><spanclass="keyword">type</span><ahref="MarshalledDataForComparison/index.html#type-t">t</a> = <ahref="MarshalledDataForComparison/argument-1-D/index.html#type-t">D.t</a></code></dt><dd><p>A default implementation of the Data API that encodes every objects as marshalled blobs with no sharing</p></dd></dl><dl><dtclass="spec module"id="module-MarshalledDataNOTForComparison"><ahref="#module-MarshalledDataNOTForComparison"class="anchor"></a><code><spanclass="keyword">module</span><ahref="MarshalledDataNOTForComparison/index.html">MarshalledDataNOTForComparison</a> : <spanclass="keyword">functor</span> (<ahref="MarshalledDataNOTForComparison/argument-1-D/index.html">D</a> : <spanclass="keyword">sig</span> ... <spanclass="keyword">end</span>) <span>-></span><ahref="index.html#module-type-Data">Data</a><spanclass="keyword">with</span><spanclass="keyword">type</span><ahref="MarshalledDataNOTForComparison/index.html#type-t">t</a> = <ahref="MarshalledDataNOTForComparison/argument-1-D/index.html#type-t">D.t</a></code></dt><dd><p>A default implementation of the Data API that encodes every objects as marshalled blobs</p></dd></dl><dl><dtclass="spec module"id="module-MarshalledNullableDataNOTForComparison"><ahref="#module-MarshalledNullableDataNOTForComparison"class="anchor"></a><code><spanclass="keyword">module</span><ahref="MarshalledNullableDataNOTForComparison/index.html">MarshalledNullableDataNOTForComparison</a> : <spanclass="keyword">functor</span> (<ahref="MarshalledNullableDataNOTForComparison/argument-1-D/index.html">D</a> : <spanclass="keyword">sig</span> ... <spanclass="keyword">end</span>) <span>-></span><ahref="index.html#module-type-Data">Data</a><spanclass="keyword">with</span><spanclass="keyword">type</span><ahref="MarshalledNullableDataNOTForComparison/index.html#type-t">t</a> = <span><ahref="MarshalledNullableDataNOTForComparison/argument-1-D/index.html#type-t">D.t</a> option</span></code></dt><dd><p>A default implementation of the Data API that encodes None as a NULL SQLite value</p></dd></dl></div></body></html>