From 797c126318b0658aa936343cb312ae93392f1a17 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 11:26:58 +0800 Subject: [PATCH] Database: Disable alchemy pools Want to use DBAPIs connection.row_factory so we can select() directly into a dict --- pyfpdb/Database.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 89d3d630..ec6b299e 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -60,11 +60,14 @@ import Configuration # Other library modules try: import sqlalchemy.pool as pool - use_pool = True + #use_pool = True + # Forcing to False so we can use connection.row_factory + use_pool = False except ImportError: log.info(_("Not using sqlalchemy connection pool.")) use_pool = False + try: from numpy import var use_numpy = True @@ -446,7 +449,8 @@ class Database: self.db_path = database log.info(_("Connecting to SQLite: %(database)s") % {'database':self.db_path}) if os.path.exists(database) or create: - self.connection = sqlite3.connect(self.db_path, detect_types=sqlite3.PARSE_DECLTYPES ) + self.connection = sqlite3.connect(self.db_path, detect_types=sqlite3.PARSE_DECLTYPES) + self.connection.row_factory = sqlite3.Row self.__connected = True sqlite3.register_converter("bool", lambda x: bool(int(x))) sqlite3.register_adapter(bool, lambda x: "1" if x else "0")