From ab004b8284a838a5d4ef5b87891bcb7d865f2e0b Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 22 Jul 2009 20:19:41 +0100 Subject: [PATCH] only update psycopg2 extensions when using it --- pyfpdb/Database.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index c1fc0664..dcf36f3e 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -29,10 +29,6 @@ import traceback from datetime import datetime, date, time, timedelta from time import time, strftime import string -from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_SERIALIZABLE -#ISOLATION_LEVEL_AUTOCOMMIT = 0 -#ISOLATION_LEVEL_READ_COMMITTED = 1 -#ISOLATION_LEVEL_SERIALIZABLE = 2 # pyGTK modules @@ -60,6 +56,14 @@ class Database: self.type = db_params['db-type'] self.backend = db_params['db-backend'] self.db_server = db_params['db-server'] + + if self.backend == self.PGSQL: + print "importing pg extensions ..." + from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_SERIALIZABLE + #ISOLATION_LEVEL_AUTOCOMMIT = 0 + #ISOLATION_LEVEL_READ_COMMITTED = 1 + #ISOLATION_LEVEL_SERIALIZABLE = 2 + # where possible avoid creating new SQL instance by using the global one passed in if sql == None: self.sql = SQL.Sql(type = self.type, db_server = db_params['db-server'])