Browse Source

SQLite

pull/36/head
Jure Šorn 5 years ago
parent
commit
e6c64d7f63
2 changed files with 12 additions and 12 deletions
  1. 12
      README.md
  2. 12
      index.html

12
README.md

@ -1743,7 +1743,7 @@ SQLite
**Server-less database engine that stores each database into separate file.**
```python
import sqlite3
db = sqlite3.connect('<path>') # Also ':memory:'.
db = sqlite3.connect('<path>') # Also ':memory:'.
...
db.close()
```
@ -1753,8 +1753,8 @@ db.close()
```python
cursor = db.execute('<query>')
if cursor:
<tuple> = cursor.fetchone() # First row.
<list> = cursor.fetchall() # Remaining rows.
<tuple> = cursor.fetchone() # First row.
<list> = cursor.fetchall() # Remaining rows.
```
* **Returned values can be of type str, int, float, bytes or None.**
@ -1766,9 +1766,9 @@ db.commit()
### Placeholders
```python
db.execute('<query>', <list/tuple>) # Replaces '?'s in query with values.
db.execute('<query>', <dict/namedtuple>) # Replaces ':<key>'s with values.
db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
db.execute('<query>', <list/tuple>) # Replaces '?'s in query with values.
db.execute('<query>', <dict/namedtuple>) # Replaces ':<key>'s with values.
db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
```
* **Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.**

12
index.html

@ -1544,7 +1544,7 @@ os.replace(<span class="hljs-keyword">from</span>, to) <span class="hl
<h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2>
<p><strong>Server-less database engine that stores each database into separate file.</strong></p>
<pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
db = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
db = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
...
db.close()
</code></pre>
@ -1554,8 +1554,8 @@ db.close()
<h3 id="read">Read</h3>
<pre><code class="python language-python hljs">cursor = db.execute(<span class="hljs-string">'&lt;query&gt;'</span>)
<span class="hljs-keyword">if</span> cursor:
&lt;tuple&gt; = cursor.fetchone() <span class="hljs-comment"># First row.</span>
&lt;list&gt; = cursor.fetchall() <span class="hljs-comment"># Remaining rows.</span>
&lt;tuple&gt; = cursor.fetchone() <span class="hljs-comment"># First row.</span>
&lt;list&gt; = cursor.fetchall() <span class="hljs-comment"># Remaining rows.</span>
</code></pre>
<ul>
<li><strong>Returned values can be of type str, int, float, bytes or None.</strong></li>
@ -1565,9 +1565,9 @@ db.close()
db.commit()
</code></pre>
<h3 id="placeholders">Placeholders</h3>
<pre><code class="python language-python hljs">db.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;list/tuple&gt;) <span class="hljs-comment"># Replaces '?'s in query with values.</span>
db.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces ':&lt;key&gt;'s with values.</span>
db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_above&gt;) <span class="hljs-comment"># Runs execute() many times.</span>
<pre><code class="python language-python hljs">db.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;list/tuple&gt;) <span class="hljs-comment"># Replaces '?'s in query with values.</span>
db.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces ':&lt;key&gt;'s with values.</span>
db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_above&gt;) <span class="hljs-comment"># Runs execute() many times.</span>
</code></pre>
<ul>
<li><strong>Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.</strong></li>

Loading…
Cancel
Save