Skip to content

Commit

Permalink
Merge pull request #11 from pablominue/pablo-develop
Browse files Browse the repository at this point in the history
Added two new methods to Query Class, updated docs
  • Loading branch information
pablominue authored Jul 2, 2024
2 parents 4f5dc6e + 1826c4e commit a73acd0
Show file tree
Hide file tree
Showing 28 changed files with 188 additions and 77 deletions.
Binary file modified docs/_build/html/.doctrees/connection.doctree
Binary file not shown.
Binary file modified docs/_build/html/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/html/.doctrees/insert.doctree
Binary file not shown.
Binary file modified docs/_build/html/.doctrees/query.doctree
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/_build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ <h1 class="logo"><a href="../index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../connection.html">SQL Connection Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../insert.html">Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../connection.html">Connections Module</a></li>
</ul>

<div class="relations">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ <h1 class="logo"><a href="../../../../index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">SQL Connection Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">Connections Module</a></li>
</ul>

<div class="relations">
Expand Down
6 changes: 3 additions & 3 deletions docs/_build/html/_modules/pysqltools/src/queries/insert.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ <h1 class="logo"><a href="../../../../index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">SQL Connection Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">Connections Module</a></li>
</ul>

<div class="relations">
Expand Down
35 changes: 32 additions & 3 deletions docs/_build/html/_modules/pysqltools/src/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,35 @@ <h1>Source code for pysqltools.src.queries.query</h1><div class="highlight"><pre
<span class="k">return</span> <span class="bp">self</span></div>


<div class="viewcode-block" id="Query.get_cte_by_identifier">
<a class="viewcode-back" href="../../../../query.html#pysqltools.src.queries.query.Query.get_cte_by_identifier">[docs]</a>
<span class="k">def</span> <span class="nf">get_cte_by_identifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Pass the identifier of one of the query CTEs and get the string containing the content of the CTE.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">ctes</span> <span class="o">=</span> <span class="p">{</span><span class="n">i</span><span class="p">:</span> <span class="n">c</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctes</span><span class="p">()}</span>
<span class="k">if</span> <span class="n">identifier</span> <span class="ow">in</span> <span class="n">ctes</span><span class="p">:</span>
<span class="k">return</span> <span class="n">ctes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">identifier</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span></div>


<div class="viewcode-block" id="Query.replace_cte">
<a class="viewcode-back" href="../../../../query.html#pysqltools.src.queries.query.Query.replace_cte">[docs]</a>
<span class="k">def</span> <span class="nf">replace_cte</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">new_cte_content</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">&quot;Query&quot;</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Given a CTE identifier, change its content with a new string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">ctes</span> <span class="o">=</span> <span class="p">{</span><span class="n">i</span><span class="p">:</span> <span class="n">c</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctes</span><span class="p">()}</span>
<span class="k">if</span> <span class="n">identifier</span> <span class="ow">in</span> <span class="n">ctes</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">get_cte_by_identifier</span><span class="p">(</span><span class="n">identifier</span><span class="p">),</span> <span class="n">new_cte_content</span>
<span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;CTE with dentifier </span><span class="si">{</span><span class="n">identifier</span><span class="si">}</span><span class="s2"> not found in Query&quot;</span><span class="p">)</span></div>


<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span>

Expand Down Expand Up @@ -257,9 +286,9 @@ <h1 class="logo"><a href="../../../../index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">SQL Connection Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../insert.html">Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../connection.html">Connections Module</a></li>
</ul>

<div class="relations">
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/connection.rst.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SQL Connection Module
Connections Module
======================

This module handles SQL database connections and query execution.
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/insert.rst.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DataFrame Insert Module
Insert Module
========================

This module contains functions to convert pandas DataFrames to SQL insert statements and execute them.
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/query.rst.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SQL Module
Query Module
==========

This module contains all the classes and functions to interact with SQL text objects.
Expand Down
16 changes: 8 additions & 8 deletions docs/_build/html/connection.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>SQL Connection Module &#8212; pysqltools 0.2.1 documentation</title>
<title>Connections Module &#8212; pysqltools 0.2.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d1102ebc" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=12dfc556" />
<script src="_static/documentation_options.js?v=37f418d5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="DataFrame Insert Module" href="insert.html" />
<link rel="prev" title="Insert Module" href="insert.html" />

<link rel="stylesheet" href="_static/custom.css" type="text/css" />

Expand All @@ -31,8 +31,8 @@

<div class="body" role="main">

<section id="sql-connection-module">
<h1>SQL Connection Module<a class="headerlink" href="#sql-connection-module" title="Link to this heading"></a></h1>
<section id="connections-module">
<h1>Connections Module<a class="headerlink" href="#connections-module" title="Link to this heading"></a></h1>
<p>This module handles SQL database connections and query execution.</p>
<dl class="py class" id="module-pysqltools.src.connection.connection">
<dt class="sig sig-object py" id="pysqltools.src.connection.connection.SQLConnection">
Expand Down Expand Up @@ -103,9 +103,9 @@ <h1 class="logo"><a href="index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">SQL Connection Module</a><ul>
<li class="toctree-l1"><a class="reference internal" href="query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="insert.html">Insert Module</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Connections Module</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#pysqltools.src.connection.connection.SQLConnection"><code class="docutils literal notranslate"><span class="pre">SQLConnection</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#classes">Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#sqlconnection">SQLConnection</a></li>
Expand All @@ -117,7 +117,7 @@ <h3>Navigation</h3>
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="insert.html" title="previous chapter">DataFrame Insert Module</a></li>
<li>Previous: <a href="insert.html" title="previous chapter">Insert Module</a></li>
</ul></li>
</ul>
</div>
Expand Down
29 changes: 21 additions & 8 deletions docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h1 id="index">Index</h1>
| <a href="#M"><strong>M</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#Q"><strong>Q</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#T"><strong>T</strong></a>
| <a href="#W"><strong>W</strong></a>
Expand All @@ -51,7 +52,7 @@ <h1 id="index">Index</h1>
<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id8">assign_parameter() (in module pysqltools.src.queries.query)</a>, <a href="query.html#pysqltools.src.queries.query.assign_parameter">[1]</a>
<li><a href="query.html#id10">assign_parameter() (in module pysqltools.src.queries.query)</a>, <a href="query.html#pysqltools.src.queries.query.assign_parameter">[1]</a>
</li>
</ul></td>
</tr></table>
Expand Down Expand Up @@ -92,6 +93,10 @@ <h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="insert.html#id3">generate_insert_query() (in module pysqltools.src.queries.insert)</a>, <a href="insert.html#pysqltools.src.queries.insert.generate_insert_query">[1]</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id4">get_cte_by_identifier() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.get_cte_by_identifier">[1]</a>
</li>
</ul></td>
</tr></table>
Expand Down Expand Up @@ -134,7 +139,7 @@ <h2 id="P">P</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="insert.html#id2">pandas_to_sql() (in module pysqltools.src.queries.insert)</a>, <a href="insert.html#pysqltools.src.queries.insert.pandas_to_sql">[1]</a>
</li>
<li><a href="query.html#id4">parameters() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.parameters">[1]</a>
<li><a href="query.html#id5">parameters() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.parameters">[1]</a>
</li>
<li><a href="insert.html#id0">prepare_value() (in module pysqltools.src.queries.insert)</a>, <a href="insert.html#pysqltools.src.queries.insert.prepare_value">[1]</a>
</li>
Expand Down Expand Up @@ -172,10 +177,18 @@ <h2 id="Q">Q</h2>
</ul></td>
</tr></table>

<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id6">replace_cte() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.replace_cte">[1]</a>
</li>
</ul></td>
</tr></table>

<h2 id="S">S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id5">selects() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.selects">[1]</a>
<li><a href="query.html#id7">selects() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.selects">[1]</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -189,15 +202,15 @@ <h2 id="S">S</h2>
<h2 id="T">T</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id6">tables() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.tables">[1]</a>
<li><a href="query.html#id8">tables() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.tables">[1]</a>
</li>
</ul></td>
</tr></table>

<h2 id="W">W</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="query.html#id7">windows() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.windows">[1]</a>
<li><a href="query.html#id9">windows() (pysqltools.src.queries.query.Query method)</a>, <a href="query.html#pysqltools.src.queries.query.Query.windows">[1]</a>
</li>
</ul></td>
</tr></table>
Expand All @@ -222,9 +235,9 @@ <h1 class="logo"><a href="index.html">pysqltools</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="query.html">SQL Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="insert.html">DataFrame Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="connection.html">SQL Connection Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="query.html">Query Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="insert.html">Insert Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="connection.html">Connections Module</a></li>
</ul>

<div class="relations">
Expand Down
Loading

0 comments on commit a73acd0

Please sign in to comment.