Browse Source

SQLite

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

3
README.md

@ -1788,6 +1788,7 @@ db.execute('<query>', <dict/namedtuple>) # Replaces ':<key>'s with values.
db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
```
* **Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.**
* **Bools will be stored and returned as ints and dates as ISO formatted strings.**
### Example
```python
@ -1806,7 +1807,7 @@ db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
from mysql import connector
db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>)
cursor = db.cursor()
cursor.execute('<query>') # Connector doesn't have execute method.
cursor.execute('<query>') # Only cursor has execute method.
cursor.execute('<query>', <list/tuple>) # Replaces '%s's in query with values.
cursor.execute('<query>', <dict/namedtuple>) # Replaces '%(<key>)s's with values.
```

3
index.html

@ -1591,6 +1591,7 @@ db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_abo
<ul>
<li><strong>Passed values can be of type str, int, float, bytes, None, bool, datetime.date or datetime.datetme.</strong></li>
<li><strong>Bools will be stored and returned as ints and dates as ISO formatted strings.</strong></li>
</ul>
<div><h3 id="example">Example</h3><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 t (a, b, c)'</span>)
@ -1606,7 +1607,7 @@ db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_abo
<span class="hljs-keyword">from</span> mysql <span class="hljs-keyword">import</span> connector
db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;, database=&lt;str&gt;)
cursor = db.cursor()
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Connector doesn't have execute method.</span>
cursor.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Only cursor has execute method.</span>
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>
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>
</code></pre></div>

Loading…
Cancel
Save