changeset 481:7e72a5f6a94b

check for any database adapters
author catherine.devlin@gmail.com
date Wed, 30 Jun 2010 00:15:35 -0400
parents e60d9192bfaa
children 8cf08822207b
files sqlpython/connections.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/connections.py	Wed May 19 15:13:44 2010 -0400
+++ b/sqlpython/connections.py	Wed Jun 30 00:15:35 2010 -0400
@@ -8,21 +8,29 @@
 import optparse
 import doctest
 
+gerald_classes = {}
+
 try:
     import cx_Oracle
+    gerald_classes['oracle'] = gerald.oracle_schema.User
 except ImportError:
     pass
 
 try:
     import psycopg2
+    gerald_classes['postgres'] = gerald.PostgresSchema
 except ImportError:
     pass
 
 try:
     import MySQLdb
+    gerald_classes['mysql'] = gerald.MySQLSchema
 except ImportError:
     pass
 
+if not gerald_classes:
+    raise ImportError, 'No Python database adapters installed!'
+
 class ObjectDescriptor(object):
     def __init__(self, name, dbobj):
         self.fullname = name
@@ -215,10 +223,6 @@
         return cx_Oracle.connect(user = self.username, password = self.password,
                                   dsn = self.dsn, mode = self.mode)    
 
-gerald_classes = {'oracle': gerald.oracle_schema.User,
-                  'postgres': gerald.PostgresSchema,
-                  'mysql': gerald.MySQLSchema }
-
 class DatabaseInstance(object):
     import_failure = None
     username = None