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

Skip to content

Commit 0085059

Browse files
committed
SQLite and Coroutines
1 parent 8739583 commit 0085059

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ SQLite
18411841
```python
18421842
import sqlite3
18431843
<con> = sqlite3.connect('<path>') # Also ':memory:'.
1844-
<con>.close()
1844+
<con>.close() # Closes the connection.
18451845
```
18461846

18471847
### Read
@@ -2308,7 +2308,7 @@ async def model(moves, state, height, width):
23082308
id_, d = await moves.get()
23092309
p = state[id_]
23102310
deltas = {D.n: P(0, -1), D.e: P(1, 0), D.s: P(0, 1), D.w: P(-1, 0)}
2311-
new_p = P(*[sum(a) for a in zip(p, deltas[d])])
2311+
new_p = P(p.x + deltas[d].x, p.y + deltas[d].y)
23122312
if 0 <= new_p.x < width-1 and 0 <= new_p.y < height:
23132313
state[id_] = new_p
23142314

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@
16571657

16581658
<div><h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2><p><strong>Server-less database engine that stores each database into a separate file.</strong></p><div><h3 id="connect">Connect</h3><p><strong>Opens a connection to the database file. Creates a new file if path doesn't exist.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
16591659
&lt;con&gt; = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
1660-
&lt;con&gt;.close()
1660+
&lt;con&gt;.close() <span class="hljs-comment"># Closes the connection.</span>
16611661
</code></pre></div></div>
16621662

16631663

@@ -2016,7 +2016,7 @@
20162016
id_, d = <span class="hljs-keyword">await</span> moves.get()
20172017
p = state[id_]
20182018
deltas = {D.n: P(<span class="hljs-number">0</span>, <span class="hljs-number">-1</span>), D.e: P(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>), D.s: P(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>), D.w: P(<span class="hljs-number">-1</span>, <span class="hljs-number">0</span>)}
2019-
new_p = P(*[sum(a) <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> zip(p, deltas[d])])
2019+
new_p = P(p.x + deltas[d].x, p.y + deltas[d].y)
20202020
<span class="hljs-keyword">if</span> <span class="hljs-number">0</span> &lt;= new_p.x &lt; width<span class="hljs-number">-1</span> <span class="hljs-keyword">and</span> <span class="hljs-number">0</span> &lt;= new_p.y &lt; height:
20212021
state[id_] = new_p
20222022

0 commit comments

Comments
 (0)