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
This commit is contained in:
Adrian Holovaty 2006-05-26 18:58:46 +00:00
parent 0c8ac0972c
commit 8e9833f261
6 changed files with 30 additions and 6 deletions

View File

@ -5,7 +5,11 @@ Requires adodbapi 2.0.1: http://adodbapi.sourceforge.net/
""" """
from django.db.backends import util from django.db.backends import util
try:
import adodbapi as Database import adodbapi as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading adodbapi module: %s" % e
import datetime import datetime
try: try:
import mx import mx

View File

@ -5,7 +5,11 @@ Requires MySQLdb: http://sourceforge.net/projects/mysql-python
""" """
from django.db.backends import util from django.db.backends import util
try:
import MySQLdb as Database import MySQLdb as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
from MySQLdb.converters import conversions from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE from MySQLdb.constants import FIELD_TYPE
import types import types

View File

@ -5,7 +5,11 @@ Requires cx_Oracle: http://www.python.net/crew/atuining/cx_Oracle/
""" """
from django.db.backends import util from django.db.backends import util
try:
import cx_Oracle as Database import cx_Oracle as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading cx_Oracle module: %s" % e
import types import types
DatabaseError = Database.Error DatabaseError = Database.Error

View File

@ -5,7 +5,11 @@ Requires psycopg 1: http://initd.org/projects/psycopg1
""" """
from django.db.backends import util from django.db.backends import util
try:
import psycopg as Database import psycopg as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading psycopg module: %s" % e
DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError

View File

@ -5,7 +5,11 @@ Requires psycopg 2: http://initd.org/projects/psycopg2
""" """
from django.db.backends import util from django.db.backends import util
try:
import psycopg2 as Database import psycopg2 as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e
DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError

View File

@ -3,7 +3,11 @@ SQLite3 backend for django. Requires pysqlite2 (http://pysqlite.org/).
""" """
from django.db.backends import util from django.db.backends import util
try:
from pysqlite2 import dbapi2 as Database from pysqlite2 import dbapi2 as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e
DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError