From 4875c3702c3d59072a3d074f4c3c384ebd6ffa9b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 23 Oct 2005 06:25:43 +0000 Subject: --- lib/sqlalchemy/databases/postgres.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/databases/postgres.py') diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 1d0349a07..547a2c0b7 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -26,8 +26,11 @@ from sqlalchemy.ansisql import * try: import psycopg2 as psycopg except: - import psycopg - + try: + import psycopg + except: + psycopg = None + class PGNumeric(sqltypes.Numeric): def get_col_spec(self): return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} @@ -70,8 +73,9 @@ def engine(opts, **params): class PGSQLEngine(ansisql.ANSISQLEngine): def __init__(self, opts, module = None, **params): if module is None: - self.module = __import__('psycopg2') - #self.module = psycopg + if psycopg is None: + raise "Couldnt locate psycopg1 or psycopg2: specify postgres module argument" + self.module = psycopg else: self.module = module self.opts = opts or {} -- cgit v1.2.1