Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1673 -- Every database backend now raises ImproperlyConfigured…

… if the relevant Python database module raises ImportError

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2993 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8e9833f26199b99180877d043bf4e944b99af39b 1 parent 0c8ac09
Adrian Holovaty authored May 26, 2006
6  django/db/backends/ado_mssql/base.py
@@ -5,7 +5,11 @@
5 5
 """
6 6
 
7 7
 from django.db.backends import util
8  
-import adodbapi as Database
  8
+try:
  9
+    import adodbapi as Database
  10
+except ImportError, e:
  11
+    from django.core.exceptions import ImproperlyConfigured
  12
+    raise ImproperlyConfigured, "Error loading adodbapi module: %s" % e
9 13
 import datetime
10 14
 try:
11 15
     import mx
6  django/db/backends/mysql/base.py
@@ -5,7 +5,11 @@
5 5
 """
6 6
 
7 7
 from django.db.backends import util
8  
-import MySQLdb as Database
  8
+try:
  9
+    import MySQLdb as Database
  10
+except ImportError, e:
  11
+    from django.core.exceptions import ImproperlyConfigured
  12
+    raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
9 13
 from MySQLdb.converters import conversions
10 14
 from MySQLdb.constants import FIELD_TYPE
11 15
 import types
6  django/db/backends/oracle/base.py
@@ -5,7 +5,11 @@
5 5
 """
6 6
 
7 7
 from django.db.backends import util
8  
-import cx_Oracle as Database
  8
+try:
  9
+    import cx_Oracle as Database
  10
+except ImportError, e:
  11
+    from django.core.exceptions import ImproperlyConfigured
  12
+    raise ImproperlyConfigured, "Error loading cx_Oracle module: %s" % e
9 13
 import types
10 14
 
11 15
 DatabaseError = Database.Error
6  django/db/backends/postgresql/base.py
@@ -5,7 +5,11 @@
5 5
 """
6 6
 
7 7
 from django.db.backends import util
8  
-import psycopg as Database
  8
+try:
  9
+    import psycopg as Database
  10
+except ImportError, e:
  11
+    from django.core.exceptions import ImproperlyConfigured
  12
+    raise ImproperlyConfigured, "Error loading psycopg module: %s" % e
9 13
 
10 14
 DatabaseError = Database.DatabaseError
11 15
 
6  django/db/backends/postgresql_psycopg2/base.py
@@ -5,7 +5,11 @@
5 5
 """
6 6
 
7 7
 from django.db.backends import util
8  
-import psycopg2 as Database
  8
+try:
  9
+    import psycopg2 as Database
  10
+except ImportError, e:
  11
+    from django.core.exceptions import ImproperlyConfigured
  12
+    raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e
9 13
 
10 14
 DatabaseError = Database.DatabaseError
11 15
 
6  django/db/backends/sqlite3/base.py
@@ -3,7 +3,11 @@
3 3
 """
4 4
 
5 5
 from django.db.backends import util
6  
-from pysqlite2 import dbapi2 as Database
  6
+try:
  7
+    from pysqlite2 import dbapi2 as Database
  8
+except ImportError, e:
  9
+    from django.core.exceptions import ImproperlyConfigured
  10
+    raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e
7 11
 
8 12
 DatabaseError = Database.DatabaseError
9 13
 

0 notes on commit 8e9833f

Please sign in to comment.
Something went wrong with that request. Please try again.