Skip to content

Commit 4e83b16

Browse files
committed
SQLite
1 parent 3ecb22f commit 4e83b16

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,12 +1536,15 @@ db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
15361536
* **Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.**
15371537

15381538
### MySQL
1539+
**Has a very similar interface, with differences listed below.**
15391540
```python
15401541
# $ pip3 install mysql-connector
15411542
from mysql import connector
15421543
db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>)
15431544
cursor = db.cursor()
1544-
cursor.execute('<query>')
1545+
cursor.execute('<query>') # Connector doesn't have execute method.
1546+
cursor.execute('<query>', <list/tuple>) # Replaces '%s's in query with values.
1547+
cursor.execute('<query>', <dict/namedtuple>) # Replaces '%(<key>)s's with values.
15451548
```
15461549

15471550

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,11 +1355,14 @@ <h3 id="placeholders">Placeholders</h3>
13551355
<li><strong>Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.</strong></li>
13561356
</ul>
13571357
<h3 id="mysql">MySQL</h3>
1358+
<p><strong>Has a very similar interface, with differences listed below.</strong></p>
13581359
<pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install mysql-connector</span>
13591360
<span class="hljs-keyword">from</span> mysql <span class="hljs-keyword">import</span> connector
13601361
db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;, database=&lt;str&gt;)
13611362
cursor = db.cursor()
1362-
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>)
1363+
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Connector doesn't have execute method.</span>
1364+
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;list/tuple&gt;) <span class="hljs-comment"># Replaces '%s's in query with values.</span>
1365+
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces '%(&lt;key&gt;)s's with values.</span>
13631366
</code></pre>
13641367
<h2 id="bytes"><a href="#bytes" name="bytes">#</a>Bytes</h2>
13651368
<p><strong>Bytes object is an immutable sequence of single bytes. Mutable version is called 'bytearray'.</strong></p>

0 commit comments

Comments
 (0)