Skip to content

Commit 3aea804

Browse files
author
Richard Jones
committed
fixed support for pysqlite2 (version 2.1.0 is the minimum version supported)
1 parent ede1c61 commit 3aea804

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ are given with the most recent entry first.
55
Fixed:
66
- sqlite module detection was broken for python 2.5 compiled without sqlite
77
support.
8+
- fixed support for pysqlite2 (version 2.1.0 is the minimum version
9+
supported)
810

911

1012
2006-10-07 1.2.1

doc/installation.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,23 @@ There's several to choose from, each with benefits and limitations:
271271
Name Speed Users Support
272272
========== =========== ===== ==============================
273273
anydbm Slowest Few Always available
274-
sqlite Fastest(*) Few Needs install (PySQLite_)
274+
sqlite Fastest(*) Few May needs install (PySQLite_)
275275
metakit Fastest(*) Few Needs install (metakit_)
276276
postgresql Fast Many Needs install/admin (psycopg_)
277277
mysql Fast Many Needs install/admin (MySQLdb_)
278278
========== =========== ===== ==============================
279279

280-
**sqlite** and **metakit**
280+
**sqlite**
281281
These use the embedded database engines PySQLite_ and metakit_ to provide
282282
very fast backends. They are not suitable for trackers which will have
283283
many simultaneous users, but require much less installation and
284284
maintenance effort than more scalable postgresql and mysql backends.
285-
If you are choosing from these two, please select sqlite.
285+
286+
SQLite is supported via PySQLite versions 1.1.7, 2.1.0 and sqlite3 (the last
287+
being bundled with Python 2.5+)
288+
**metakit**
289+
Similar performance to sqlite. If you are choosing between these two,
290+
please select sqlite.
286291
**postgresql**
287292
Backend for popular RDBMS PostgreSQL. You must read doc/postgresql.txt for
288293
additional installation steps and requirements. You must also configure

roundup/backends/back_sqlite.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.47 2006-10-04 01:12:00 richard Exp $
1+
# $Id: back_sqlite.py,v 1.48 2006-10-10 03:55:31 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -13,15 +13,17 @@
1313

1414
from roundup import hyperdb, date, password
1515
from roundup.backends import rdbms_common
16-
is_sqlite3 = False
16+
sqlite_version = None
1717
try:
1818
import sqlite
19+
sqlite_version = 1
1920
except ImportError:
2021
try:
2122
from pysqlite2 import dbapi2 as sqlite
23+
sqlite_version = 2
2224
except ImportError:
2325
import sqlite3 as sqlite
24-
is_sqlite3 = True
26+
sqlite_version = 3
2527

2628
def db_exists(config):
2729
return os.path.exists(os.path.join(config.DATABASE, 'db'))
@@ -31,7 +33,7 @@ def db_nuke(config):
3133

3234
class Database(rdbms_common.Database):
3335
# char to use for positional arguments
34-
if is_sqlite3:
36+
if sqlite_version in (2,3):
3537
arg = '?'
3638
else:
3739
arg = '%s'
@@ -98,12 +100,12 @@ def sql_open_connection(self):
98100
logging.getLogger('hyperdb').info('open database %r'%db)
99101
# set a 30 second timeout (extraordinarily generous) for handling
100102
# locked database
101-
if is_sqlite3:
102-
conn = sqlite.connect(db, 30)
103-
conn.row_factory = sqlite.Row
104-
else:
103+
if sqlite_version == 1:
105104
conn = sqlite.connect(db=db)
106105
conn.db.sqlite_busy_handler(self.sqlite_busy_handler)
106+
else:
107+
conn = sqlite.connect(db, timeout=30)
108+
conn.row_factory = sqlite.Row
107109
cursor = conn.cursor()
108110
return (conn, cursor)
109111

@@ -264,7 +266,7 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
264266
# generate the new value for the Interval int column
265267
if name.endswith('_int__'):
266268
name = name[2:-6]
267-
if is_sqlite3:
269+
if sqlite_version in (2,3):
268270
try:
269271
v = hyperdb.Interval(entry[name]).as_seconds()
270272
except IndexError:
@@ -273,12 +275,12 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
273275
v = hyperdb.Interval(entry[name]).as_seconds()
274276
else:
275277
v = None
276-
elif is_sqlite3:
278+
elif sqlite_version in (2,3):
277279
try:
278280
v = entry[name]
279281
except IndexError:
280282
v = None
281-
elif (not is_sqlite3 and entry.has_key(name)):
283+
elif (sqlite_version == 1 and entry.has_key(name)):
282284
v = entry[name]
283285
else:
284286
v = None
@@ -368,7 +370,7 @@ def create_class(self, spec):
368370
vals = (spec.classname, 1)
369371
self.sql(sql, vals)
370372

371-
if is_sqlite3:
373+
if sqlite_version in (2,3):
372374
def load_journal(self, classname, cols, nodeid):
373375
'''We need to turn the sqlite3.Row into a tuple so it can be
374376
unpacked'''

0 commit comments

Comments
 (0)