Files
aiodatalite/docs/_build/html/datalite.html
2020-08-14 11:45:39 +03:00

399 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>datalite package &mdash; Datalite v0.5.2 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Welcome to Datalites documentation!" href="index.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home" alt="Documentation Home"> Datalite
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">datalite package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#datalite-module">datalite Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-datalite.fetch">datalite.fetch module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-datalite.migrations">datalite.migrations module</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Datalite</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>datalite package</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/datalite.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="datalite-package">
<h1>datalite package<a class="headerlink" href="#datalite-package" title="Permalink to this headline"></a></h1>
<div class="section" id="datalite-module">
<h2>datalite Module<a class="headerlink" href="#datalite-module" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt id="datalite.datalite">
<code class="sig-prename descclassname">&#64;</code><code class="sig-prename descclassname">datalite.</code><code class="sig-name descname">datalite</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">db_path</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">type_overload</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>Dict<span class="p">[</span>Optional<span class="p">[</span>type<span class="p">]</span><span class="p">, </span>str<span class="p">]</span><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; Callable<a class="headerlink" href="#datalite.datalite" title="Permalink to this definition"></a></dt>
<dd><p>Bind a dataclass to a sqlite3 database. This adds new methods to the class, such as
<cite>create_entry()</cite>, <cite>remove_entry()</cite> and <cite>update_entry()</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>db_path</strong> Path of the database to be binded.</p></li>
<li><p><strong>type_overload</strong> Type overload dictionary.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The new dataclass.</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="module-datalite.fetch">
<span id="datalite-fetch-module"></span><h2>datalite.fetch module<a class="headerlink" href="#module-datalite.fetch" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt id="datalite.fetch.fetch_all">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_all</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">page</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">0</span></em>, <em class="sig-param"><span class="n">element_count</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">10</span></em><span class="sig-paren">)</span> &#x2192; tuple<a class="headerlink" href="#datalite.fetch.fetch_all" title="Permalink to this definition"></a></dt>
<dd><p>Fetchall the records in the bound database.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class of the records.</p></li>
<li><p><strong>page</strong> Which page to retrieve, default all. (0 means closed).</p></li>
<li><p><strong>element_count</strong> Element count in each page.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>All the records of type <a href="#id1"><span class="problematic" id="id2">class_</span></a> in
the bound database as a tuple.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.fetch_equals">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_equals</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">field</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">value</span><span class="p">:</span> <span class="n">Any</span></em><span class="sig-paren">)</span> &#x2192; Any<a class="headerlink" href="#datalite.fetch.fetch_equals" title="Permalink to this definition"></a></dt>
<dd><p>Fetch a <a href="#id3"><span class="problematic" id="id4">class_</span></a> type variable from its bound db.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class to fetch.</p></li>
<li><p><strong>field</strong> Field to check for, by default, object id.</p></li>
<li><p><strong>value</strong> Value of the field to check for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The object whose data is taken from the database.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.fetch_from">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_from</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">obj_id</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; Any<a class="headerlink" href="#datalite.fetch.fetch_from" title="Permalink to this definition"></a></dt>
<dd><p>Fetch a <a href="#id5"><span class="problematic" id="id6">class_</span></a> type variable from its bound dv.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class to fetch from.</p></li>
<li><p><strong>obj_id</strong> Unique object id of the object.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The fetched object.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.fetch_if">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_if</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">condition</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">page</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">0</span></em>, <em class="sig-param"><span class="n">element_count</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">10</span></em><span class="sig-paren">)</span> &#x2192; tuple<a class="headerlink" href="#datalite.fetch.fetch_if" title="Permalink to this definition"></a></dt>
<dd><p>Fetch all <a href="#id7"><span class="problematic" id="id8">class_</span></a> type variables from the bound db,
provided they fit the given condition</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class type to fetch.</p></li>
<li><p><strong>condition</strong> Condition to check for.</p></li>
<li><p><strong>page</strong> Which page to retrieve, default all. (0 means closed).</p></li>
<li><p><strong>element_count</strong> Element count in each page.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple of records that fit the given condition
of given type <a href="#id9"><span class="problematic" id="id10">class_</span></a>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.fetch_range">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_range</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">range_</span><span class="p">:</span> <span class="n">range</span></em><span class="sig-paren">)</span> &#x2192; tuple<a class="headerlink" href="#datalite.fetch.fetch_range" title="Permalink to this definition"></a></dt>
<dd><p>Fetch the records in a given range of object ids.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class of the records.</p></li>
<li><p><strong>range</strong> Range of the object ids.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple of <a href="#id11"><span class="problematic" id="id12">class_</span></a> type objects whose values
come from the <a href="#id13"><span class="problematic" id="id14">class_</span></a> bound database.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.fetch_where">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">fetch_where</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">field</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">value</span><span class="p">:</span> <span class="n">Any</span></em>, <em class="sig-param"><span class="n">page</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">0</span></em>, <em class="sig-param"><span class="n">element_count</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">10</span></em><span class="sig-paren">)</span> &#x2192; tuple<a class="headerlink" href="#datalite.fetch.fetch_where" title="Permalink to this definition"></a></dt>
<dd><p>Fetch all <a href="#id15"><span class="problematic" id="id16">class_</span></a> type variables from the bound db,
provided that the field of the records fit the
given value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class of the records.</p></li>
<li><p><strong>field</strong> Field to check.</p></li>
<li><p><strong>value</strong> Value to check for.</p></li>
<li><p><strong>page</strong> Which page to retrieve, default all. (0 means closed).</p></li>
<li><p><strong>element_count</strong> Element count in each page.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple of the records.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="datalite.fetch.is_fetchable">
<code class="sig-prename descclassname">datalite.fetch.</code><code class="sig-name descname">is_fetchable</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">obj_id</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#datalite.fetch.is_fetchable" title="Permalink to this definition"></a></dt>
<dd><p>Check if a record is fetchable given its obj_id and
<a href="#id17"><span class="problematic" id="id18">class_</span></a> type.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Class type of the object.</p></li>
<li><p><strong>obj_id</strong> Unique obj_id of the object.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>If the object is fetchable.</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="module-datalite.migrations">
<span id="datalite-migrations-module"></span><h2>datalite.migrations module<a class="headerlink" href="#module-datalite.migrations" title="Permalink to this headline"></a></h2>
<p>Migrations module deals with migrating data when the object
definitions change. This functions deal with Schema Migrations.</p>
<dl class="py function">
<dt id="datalite.migrations.basic_migrate">
<code class="sig-prename descclassname">datalite.migrations.</code><code class="sig-name descname">basic_migrate</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">class_</span><span class="p">:</span> <span class="n">type</span></em>, <em class="sig-param"><span class="n">column_transfer</span><span class="p">:</span> <span class="n">dict</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#datalite.migrations.basic_migrate" title="Permalink to this definition"></a></dt>
<dd><p>Given a class, compare its previous table,
delete the fields that no longer exist,
create new columns for new fields. If the
column_flow parameter is given, migrate elements
from previous column to the new ones.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>class</strong> Datalite class to migrate.</p></li>
<li><p><strong>column_transfer</strong> A dictionary showing which
columns will be copied to new ones.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None.</p>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="index.html" class="btn btn-neutral float-left" title="Welcome to Datalites documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, Ege Ozkan
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>