move sqlite charset fix to Configuration.py from Database.py, make separate not_needed variables in Charset.py in case we want to update them separately

This commit is contained in:
sqlcoder
2010-01-30 11:05:34 +00:00
parent d147187a71
commit 9932025271
3 changed files with 17 additions and 14 deletions
+2 -9
View File
@@ -372,7 +372,6 @@ class Database:
print msg
raise FpdbError(msg)
elif backend == Database.SQLITE:
log.info("Connecting to SQLite: %(database)s" % {'database':database})
import sqlite3
if use_pool:
sqlite3 = pool.manage(sqlite3, pool_size=1)
@@ -385,7 +384,8 @@ class Database:
log.info("Creating directory: '%s'" % (self.config.dir_databases))
os.mkdir(self.config.dir_databases)
database = os.path.join(self.config.dir_databases, database)
log.info(" sqlite db: " + database)
log.info("Connecting to SQLite: %(database)s" % {'database':database})
print "Connecting to SQLite: %(database)s" % {'database':database}
self.connection = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
sqlite3.register_converter("bool", lambda x: bool(int(x)))
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
@@ -399,13 +399,6 @@ class Database:
self.cursor = self.connection.cursor()
self.cursor.execute('PRAGMA temp_store=2') # use memory for temp tables/indexes
self.cursor.execute('PRAGMA synchronous=0') # don't wait for file writes to finish
# sqlcoder: this assignment fixes unicode problems for me with sqlite (windows, cp1252)
# feel free to remove or improve this if you understand the problems
# better than me (not hard!)
# I think maybe we need a separate "not_needed" flag for each of the routines
# in Charset.py???
# Charset.not_needed = True
else:
raise FpdbError("unrecognised database backend:"+backend)