Skip to content

Commit a85a3ec

Browse files
committed
issue2551302 - Remove support for sqlite version 1 from back_sqlite.py
Remove sqlite v1 support and document.
1 parent 3180dc6 commit a85a3ec

File tree

4 files changed

+19
-39
lines changed

4 files changed

+19
-39
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ Fixed:
128128
Python fixed. (John Rouillard)
129129
- issue2551334 - number of test bugs that prevented test suite from
130130
running under Windows Python are fixed. WIP. (John Rouillard)
131+
- issue2551302 - Remove support for sqlite version 1 from
132+
back_sqlite.py. We have been using sqlite3 for over a decade. (John
133+
Rouillard)
131134

132135
Features:
133136

doc/installation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ mysql Fast Many Needs install/admin (MySQLdb_)
612612
simultaneous users, but requires much less installation and maintenance
613613
effort than more scalable postgresql and mysql backends.
614614

615-
SQLite is supported via PySQLite versions 1.1.7, 2.1.0 and sqlite3 (the last
615+
SQLite is supported via PySQLite version 2.1.0 and sqlite3 (the last
616616
being bundled with Python 2.5+)
617617

618618
Installed SQLite should be the latest version available (3.9.0 or newer).

doc/upgrading.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ The history command gets a new optional argument ``raw`` that produces
486486
the old style output. The old style is (marginally) more useful for
487487
script automation.
488488

489+
Deprecation Notices (info)
490+
--------------------------
491+
492+
Support for SQLite version 1 has been removed in 2.4.0.
493+
489494
.. index:: Upgrading; 2.2.0 to 2.3.0
490495

491496
Migrating from 2.2.0 to 2.3.0

roundup/backends/back_sqlite.py

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
'- %s found' % sqlite.version)
3939
sqlite_version = 2
4040
except ImportError:
41-
import sqlite
42-
sqlite_version = 1
41+
raise ValueError("Unable to import sqlite3 or sqlite 2.")
4342

4443

4544
def db_exists(config):
@@ -61,10 +60,7 @@ class Database(rdbms_common.Database):
6160
"""
6261

6362
# char to use for positional arguments
64-
if sqlite_version in (2, 3):
65-
arg = '?'
66-
else:
67-
arg = '%s'
63+
arg = '?'
6864

6965
dbtype = "sqlite"
7066

@@ -144,21 +140,6 @@ def getOTKManager(self):
144140
self.Otk = sessions_sqlite.OneTimeKeys(self)
145141
return self.Otk
146142

147-
def sqlite_busy_handler(self, data, table, count):
148-
"""invoked whenever SQLite tries to access a database that is locked"""
149-
now = time.time()
150-
if count == 1:
151-
# Timeout for handling locked database (default 30s)
152-
self._busy_handler_endtime = now + self.config.RDBMS_SQLITE_TIMEOUT
153-
elif now > self._busy_handler_endtime:
154-
# timeout expired - no more retries
155-
return 0
156-
# sleep adaptively as retry count grows,
157-
# starting from about half a second
158-
time_to_sleep = 0.01 * (2 << min(5, count))
159-
time.sleep(time_to_sleep)
160-
return 1
161-
162143
def sql_open_connection(self, dbname=None):
163144
"""Open a standard, non-autocommitting connection.
164145
@@ -174,14 +155,8 @@ def sql_open_connection(self, dbname=None):
174155
else:
175156
db = os.path.join(self.config.DATABASE, 'db')
176157
logging.getLogger('roundup.hyperdb').info('open database %r' % db)
177-
# set timeout (30 second default is extraordinarily generous)
178-
# for handling locked database
179-
if sqlite_version == 1:
180-
conn = sqlite.connect(db=db)
181-
conn.db.sqlite_busy_handler(self.sqlite_busy_handler)
182-
else:
183-
conn = sqlite.connect(db, timeout=self.config.RDBMS_SQLITE_TIMEOUT)
184-
conn.row_factory = sqlite.Row
158+
conn = sqlite.connect(db, timeout=self.config.RDBMS_SQLITE_TIMEOUT)
159+
conn.row_factory = sqlite.Row
185160

186161
# pysqlite2 / sqlite3 want us to store Unicode in the db but
187162
# that's not what's been done historically and it's definitely
@@ -398,8 +373,6 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
398373
v = entry[name]
399374
except IndexError:
400375
v = None
401-
elif (sqlite_version == 1 and name in entry):
402-
v = entry[name]
403376
else:
404377
v = None
405378
if name == 'id':
@@ -543,14 +516,13 @@ def create_class(self, spec):
543516
vals = (spec.classname, 1)
544517
self.sql(sql, vals)
545518

546-
if sqlite_version in (2, 3):
547-
def load_journal(self, classname, cols, nodeid):
548-
"""We need to turn the sqlite3.Row into a tuple so it can be
519+
def load_journal(self, classname, cols, nodeid):
520+
"""We need to turn the sqlite3.Row into a tuple so it can be
549521
unpacked"""
550-
l = rdbms_common.Database.load_journal(self,
551-
classname, cols, nodeid)
552-
cols = range(5)
553-
return [[row[col] for col in cols] for row in l]
522+
l = rdbms_common.Database.load_journal(self,
523+
classname, cols, nodeid)
524+
cols = range(5)
525+
return [[row[col] for col in cols] for row in l]
554526

555527

556528
class sqliteClass:

0 commit comments

Comments
 (0)