From: Robert Leftwich Date: Tue, 10 Jan 2006 00:49:47 +0000 (+0000) Subject: r810@lightspeed: robert | 2006-01-10 11:49:18 +1100 X-Git-Tag: rel_0_1_0~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=060b8f0478710e9891e73f8832d1883ae0ad999b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git r810@lightspeed: robert | 2006-01-10 11:49:18 +1100 Added check for __version__ to determine if pyscopg is v1 or v2 --- diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 7cfcb8382f..6b1dbef465 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -118,10 +118,16 @@ class PGSQLEngine(ansisql.ANSISQLEngine): else: self.module = module # figure psycopg version 1 or 2 - if self.module.__name__.endswith('psycopg2'): - self.version = 2 - else: - self.version = 1 + try: + if self.module.__version__.startswith('2'): + self.version = 2 + else: + self.version = 1 + except: + if self.module.__name__.endswith('psycopg2'): + self.version = 2 + else: + self.version = 1 self.opts = opts or {} ansisql.ANSISQLEngine.__init__(self, **params)