Browse Source

SQLite create

pull/40/head
Jure Šorn 5 years ago
parent
commit
95f225506b
2 changed files with 14 additions and 0 deletions
  1. 8
      README.md
  2. 6
      index.html

8
README.md

@ -1760,6 +1760,14 @@ db.close()
```
* **New database will be created if path doesn't exist.**
### Create
```python
>>> db.execute('create table t (a, b, c)')
>>> db.execute('insert into t values (1, 2, 3)')
>>> db.execute('select * from t').fetchall()
[(1, 2, 3)]
```
### Read
```python
cursor = db.execute('<query>')

6
index.html

@ -1567,6 +1567,12 @@ db.close()
<ul>
<li><strong>New database will be created if path doesn't exist.</strong></li>
</ul>
<div><h3 id="create">Create</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'create table t (a, b, c)'</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'insert into t values (1, 2, 3)'</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from t'</span>).fetchall()
[(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)]
</code></pre></div>
<div><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>

Loading…
Cancel
Save