Two patches that solve this in different ways (both against trunk, but would
probably apply cleanly to any recent version):
1 - patch to welcome application
diff -r 1462bcd5ea7a applications/welcome/models/db.py
--- a/applications/welcome/models/db.py Fri Sep 02 20:41:54 2011 -0500
+++ b/applications/welcome/models/db.py Fri Sep 02 23:04:10 2011 -0400
@@ -7,7 +7,14 @@
if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
- db = DAL('sqlite://storage.sqlite')
+ db_url = 'sqlite://storage.sqlite'
+ if db_url[:7]=='sqlite:':
+ import sqlite3
+ db = DAL(db_url,
driver_args={'detect_types':sqlite3.PARSE_DECLTYPES})
+ del sqlite3
+ else:
+ db = DAL(db_url)
+ del db_url
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore')
This is perfectly backward compatible - it would only apply to new
applications generated by the wizard, and not change behavior of old ones
(and, I delete sqlite3 and db_url at the end so that no new variables are
introduced in scope). But it is awkward and confusing.
2 - I believe the existing behavior is a bug, in which case this could be
fixed in DAL.py;
diff -r 1462bcd5ea7a gluon/dal.py
--- a/gluon/dal.py Fri Sep 02 20:41:54 2011 -0500
+++ b/gluon/dal.py Fri Sep 02 23:16:58 2011 -0400
@@ -1581,6 +1581,9 @@
dbpath =
os.path.join(self.folder.decode(path_encoding).encode('utf8'),dbpath)
if not 'check_same_thread' in driver_args:
driver_args['check_same_thread'] = False
+ if not 'detect_types' in driver_args:
+ driver_args['detect_types'] = self.driver.PARSE_DECLTYPES
+
def connect(dbpath=dbpath, driver_args=driver_args):
return self.driver.Connection(dbpath, **driver_args)
self.pool_connection(connect)
Which I believe is simpler and more elegant.
(minor: I prefer to write it as "if 'detect_types' not in driver_args", but
I stayed with the original style).