Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95f2255

Browse files
committed
SQLite create
1 parent 7417773 commit 95f2255

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,14 @@ db.close()
17601760
```
17611761
* **New database will be created if path doesn't exist.**
17621762

1763+
### Create
1764+
```python
1765+
>>> db.execute('create table t (a, b, c)')
1766+
>>> db.execute('insert into t values (1, 2, 3)')
1767+
>>> db.execute('select * from t').fetchall()
1768+
[(1, 2, 3)]
1769+
```
1770+
17631771
### Read
17641772
```python
17651773
cursor = db.execute('<query>')

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,12 @@
15671567
<ul>
15681568
<li><strong>New database will be created if path doesn't exist.</strong></li>
15691569
</ul>
1570+
<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>)
1571+
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'insert into t values (1, 2, 3)'</span>)
1572+
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from t'</span>).fetchall()
1573+
[(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)]
1574+
</code></pre></div>
1575+
15701576
<div><h3 id="read">Read</h3><pre><code class="python language-python hljs">cursor = db.execute(<span class="hljs-string">'&lt;query&gt;'</span>)
15711577
<span class="hljs-keyword">if</span> cursor:
15721578
&lt;tuple&gt; = cursor.fetchone() <span class="hljs-comment"># First row.</span>

0 commit comments

Comments
 (0)