Skip to content

Commit 21cc09f

Browse files
committed
SQLite
1 parent 9943ca7 commit 21cc09f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,12 +1874,13 @@ db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
18741874

18751875
### Example
18761876
**In this example values are not actually saved because `'db.commit()'` is omitted!**
1877+
18771878
```python
18781879
>>> db = sqlite3.connect('test.db')
1879-
>>> db.execute('create table t (a, b, c)')
1880-
>>> db.execute('insert into t values (1, 2, 3)')
1881-
>>> db.execute('select * from t').fetchall()
1882-
[(1, 2, 3)]
1880+
>>> db.execute('create table person (id integer primary key, name, height)')
1881+
>>> db.execute('insert into person values (null, ?, ?)', ('Jean-Luc', 187))
1882+
>>> db.execute('select * from person').fetchall()
1883+
[(1, 'Jean-Luc', 187)]
18831884
```
18841885

18851886
### MySQL

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,10 @@
16741674

16751675

16761676
<div><h3 id="example">Example</h3><p><strong>In this example values are not actually saved because <code class="python hljs"><span class="hljs-string">'db.commit()'</span></code> is omitted!</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>db = sqlite3.connect(<span class="hljs-string">'test.db'</span>)
1677-
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'create table t (a, b, c)'</span>)
1678-
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'insert into t values (1, 2, 3)'</span>)
1679-
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from t'</span>).fetchall()
1680-
[(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)]
1677+
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'create table person (id integer primary key, name, height)'</span>)
1678+
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'insert into person values (null, ?, ?)'</span>, (<span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>))
1679+
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from person'</span>).fetchall()
1680+
[(<span class="hljs-number">1</span>, <span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>)]
16811681
</code></pre></div>
16821682

16831683

0 commit comments

Comments
 (0)