changeset 7921:e3975f679bf1

issue2551302 - Remove support for sqlite version 1 from back_sqlite.py Remove sqlite v1 support and document.
author John Rouillard <rouilj@ieee.org>
date Tue, 30 Apr 2024 22:16:22 -0400
parents 6aa0525187cd
children ded9f1c3f112
files CHANGES.txt doc/installation.txt doc/upgrading.txt roundup/backends/back_sqlite.py
diffstat 4 files changed, 19 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Mon Apr 29 04:17:10 2024 -0400
+++ b/CHANGES.txt	Tue Apr 30 22:16:22 2024 -0400
@@ -128,6 +128,9 @@
   Python fixed. (John Rouillard)
 - issue2551334 - number of test bugs that prevented test suite from
   running under Windows Python are fixed. WIP. (John Rouillard)
+- issue2551302 - Remove support for sqlite version 1 from
+  back_sqlite.py. We have been using sqlite3 for over a decade. (John
+  Rouillard)
 
 Features:
 
--- a/doc/installation.txt	Mon Apr 29 04:17:10 2024 -0400
+++ b/doc/installation.txt	Tue Apr 30 22:16:22 2024 -0400
@@ -612,7 +612,7 @@
   simultaneous users, but requires much less installation and maintenance
   effort than more scalable postgresql and mysql backends.
 
-  SQLite is supported via PySQLite versions 1.1.7, 2.1.0 and sqlite3 (the last
+  SQLite is supported via PySQLite version 2.1.0 and sqlite3 (the last
   being bundled with Python 2.5+)
 
   Installed SQLite should be the latest version available (3.9.0 or newer).
--- a/doc/upgrading.txt	Mon Apr 29 04:17:10 2024 -0400
+++ b/doc/upgrading.txt	Tue Apr 30 22:16:22 2024 -0400
@@ -486,6 +486,11 @@
 the old style output. The old style is (marginally) more useful for
 script automation.
 
+Deprecation Notices (info)
+--------------------------
+
+Support for SQLite version 1 has been removed in 2.4.0.
+
 .. index:: Upgrading; 2.2.0 to 2.3.0
 
 Migrating from 2.2.0 to 2.3.0
--- a/roundup/backends/back_sqlite.py	Mon Apr 29 04:17:10 2024 -0400
+++ b/roundup/backends/back_sqlite.py	Tue Apr 30 22:16:22 2024 -0400
@@ -38,8 +38,7 @@
                              '- %s found' % sqlite.version)
         sqlite_version = 2
     except ImportError:
-        import sqlite
-        sqlite_version = 1
+        raise ValueError("Unable to import sqlite3 or sqlite 2.")
 
 
 def db_exists(config):
@@ -61,10 +60,7 @@
     """
 
     # char to use for positional arguments
-    if sqlite_version in (2, 3):
-        arg = '?'
-    else:
-        arg = '%s'
+    arg = '?'
 
     dbtype = "sqlite"
 
@@ -144,21 +140,6 @@
                 self.Otk = sessions_sqlite.OneTimeKeys(self)
         return self.Otk
 
-    def sqlite_busy_handler(self, data, table, count):
-        """invoked whenever SQLite tries to access a database that is locked"""
-        now = time.time()
-        if count == 1:
-            # Timeout for handling locked database (default 30s)
-            self._busy_handler_endtime = now + self.config.RDBMS_SQLITE_TIMEOUT
-        elif now > self._busy_handler_endtime:
-            # timeout expired - no more retries
-            return 0
-        # sleep adaptively as retry count grows,
-        # starting from about half a second
-        time_to_sleep = 0.01 * (2 << min(5, count))
-        time.sleep(time_to_sleep)
-        return 1
-
     def sql_open_connection(self, dbname=None):
         """Open a standard, non-autocommitting connection.
 
@@ -174,14 +155,8 @@
         else:
             db = os.path.join(self.config.DATABASE, 'db')
         logging.getLogger('roundup.hyperdb').info('open database %r' % db)
-        # set timeout (30 second default is extraordinarily generous)
-        # for handling locked database
-        if sqlite_version == 1:
-            conn = sqlite.connect(db=db)
-            conn.db.sqlite_busy_handler(self.sqlite_busy_handler)
-        else:
-            conn = sqlite.connect(db, timeout=self.config.RDBMS_SQLITE_TIMEOUT)
-            conn.row_factory = sqlite.Row
+        conn = sqlite.connect(db, timeout=self.config.RDBMS_SQLITE_TIMEOUT)
+        conn.row_factory = sqlite.Row
 
         # pysqlite2 / sqlite3 want us to store Unicode in the db but
         # that's not what's been done historically and it's definitely
@@ -398,8 +373,6 @@
                             v = entry[name]
                         except IndexError:
                             v = None
-                    elif (sqlite_version == 1 and name in entry):
-                        v = entry[name]
                     else:
                         v = None
                     if name == 'id':
@@ -543,14 +516,13 @@
         vals = (spec.classname, 1)
         self.sql(sql, vals)
 
-    if sqlite_version in (2, 3):
-        def load_journal(self, classname, cols, nodeid):
-            """We need to turn the sqlite3.Row into a tuple so it can be
+    def load_journal(self, classname, cols, nodeid):
+        """We need to turn the sqlite3.Row into a tuple so it can be
             unpacked"""
-            l = rdbms_common.Database.load_journal(self,
-                                                   classname, cols, nodeid)
-            cols = range(5)
-            return [[row[col] for col in cols] for row in l]
+        l = rdbms_common.Database.load_journal(self,
+                                               classname, cols, nodeid)
+        cols = range(5)
+        return [[row[col] for col in cols] for row in l]
 
 
 class sqliteClass:

Roundup Issue Tracker: http://roundup-tracker.org/