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

[tor-commits] [stem/master] Enforce read-only usage of manual database



commit a8296d6071a253b4f2265b651b6d5b5c455278e7
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Feb 9 18:58:59 2020 -0800

    Enforce read-only usage of manual database
    
    Now that we're using python 3.x our sqlite module's uri mode can allow us to
    open our cache in a read-only manner...
    
      https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
---
 stem/manual.py | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/stem/manual.py b/stem/manual.py
index c1b4bd8f..1a0816c8 100644
--- a/stem/manual.py
+++ b/stem/manual.py
@@ -142,16 +142,11 @@ def query(query, *param):
   # The only reason to explicitly close the sqlite connection is to ensure
   # transactions are committed. Since we're only using read-only access this
   # doesn't matter, and can allow interpreter shutdown to do the needful.
-  #
-  # TODO: When we only support python 3.4+ we can use sqlite's uri argument
-  # to enforce a read-only connection...
-  #
-  #   https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
 
   global DATABASE
 
   if DATABASE is None:
-    DATABASE = sqlite3.connect(CACHE_PATH)
+    DATABASE = sqlite3.connect('file:%s?mode=ro' % CACHE_PATH, uri=True)
 
   return DATABASE.execute(query, param)
 



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