[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Fetch sqlite results along with execute



commit 893365d98e42ae749e9a5efd8f0bb115d171a5b1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Aug 26 14:08:23 2017 -0700

    Fetch sqlite results along with execute
    
    Tutorials invoked execute then followed it with a fetch call, but turns out
    execute returns a cursor object. So no need to split them up or have a separate
    cursor.
---
 stem/manual.py | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/stem/manual.py b/stem/manual.py
index b2f31a9e..0e2ea8d8 100644
--- a/stem/manual.py
+++ b/stem/manual.py
@@ -360,23 +360,16 @@ class Manual(object):
 
   @staticmethod
   def _from_sqlite_cache(path):
-    with database(path) as cursor:
-      cursor.execute('SELECT name, synopsis, description, man_commit, stem_commit FROM metadata')
-      name, synopsis, description, man_commit, stem_commit = cursor.fetchone()
+    with sqlite3.connect(path) as conn:
+      name, synopsis, description, man_commit, stem_commit = conn.execute('SELECT name, synopsis, description, man_commit, stem_commit FROM metadata').fetchone()
 
-      cursor.execute('SELECT name, description FROM commandline')
-      commandline = dict(cursor.fetchall())
+      commandline = dict(conn.execute('SELECT name, description FROM commandline').fetchall())
+      signals = dict(conn.execute('SELECT name, description FROM signals').fetchall())
+      files = dict(conn.execute('SELECT name, description FROM files').fetchall())
 
-      cursor.execute('SELECT name, description FROM signals')
-      signals = dict(cursor.fetchall())
-
-      cursor.execute('SELECT name, description FROM files')
-      files = dict(cursor.fetchall())
-
-      cursor.execute('SELECT name, category, usage, summary, description FROM torrc')
       config_options = OrderedDict()
 
-      for entry in cursor.fetchall():
+      for entry in conn.execute('SELECT name, category, usage, summary, description FROM torrc').fetchall():
         option, category, usage, summary, option_description = entry
         config_options[option] = ConfigOption(option, category, usage, summary, option_description)
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits