Browse Source

SQLite

pull/54/head
Jure Šorn 4 years ago
parent
commit
e17bd8f958
2 changed files with 6 additions and 4 deletions
  1. 5
      README.md
  2. 5
      index.html

5
README.md

@ -1877,8 +1877,9 @@ db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
```python ```python
>>> db = sqlite3.connect('test.db') >>> db = sqlite3.connect('test.db')
>>> db.execute('create table person (id integer primary key, name, height)')
>>> db.execute('insert into person values (null, ?, ?)', ('Jean-Luc', 187))
>>> db.execute('create table person (person_id integer primary key, name, height)')
>>> db.execute('insert into person values (null, ?, ?)', ('Jean-Luc', 187)).lastrowid
1
>>> db.execute('select * from person').fetchall() >>> db.execute('select * from person').fetchall()
[(1, 'Jean-Luc', 187)] [(1, 'Jean-Luc', 187)]
``` ```

5
index.html

@ -1674,8 +1674,9 @@ db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_abo
<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>) <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>)
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'create table person (id integer primary key, name, height)'</span>)
<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>))
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'create table person (person_id integer primary key, name, height)'</span>)
<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>)).lastrowid
<span class="hljs-number">1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from person'</span>).fetchall() <span class="hljs-meta">&gt;&gt;&gt; </span>db.execute(<span class="hljs-string">'select * from person'</span>).fetchall()
[(<span class="hljs-number">1</span>, <span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>)] [(<span class="hljs-number">1</span>, <span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>)]
</code></pre></div> </code></pre></div>

Loading…
Cancel
Save