Skip to content

Commit

Permalink
Made various negligible formatting cleanups to the database backends
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5983 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Aug 20, 2007
1 parent 14db373 commit b367ec2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion django/db/backends/ado_mssql/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import adodbapi as Database import adodbapi as Database
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading adodbapi module: %s" % e raise ImproperlyConfigured("Error loading adodbapi module: %s" % e)
import datetime import datetime
try: try:
import mx import mx
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/dummy/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def __init__(self, **kwargs):
pass pass


def close(self): def close(self):
pass # close() pass
4 changes: 2 additions & 2 deletions django/db/backends/mysql/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import MySQLdb as Database import MySQLdb as Database
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)


# We want version (1, 2, 1, 'final', 2) or later. We can't just use # We want version (1, 2, 1, 'final', 2) or later. We can't just use
# lexicographic ordering in this check because then (1, 2, 1, 'gamma') # lexicographic ordering in this check because then (1, 2, 1, 'gamma')
# inadvertently passes the version test. # inadvertently passes the version test.
version = Database.version_info version = Database.version_info
if (version < (1,2,1) or (version[:3] == (1, 2, 1) and if (version < (1,2,1) or (version[:3] == (1, 2, 1) and
(len(version) < 5 or version[3] != 'final' or version[4] < 2))): (len(version) < 5 or version[3] != 'final' or version[4] < 2))):
raise ImportError, "MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__ raise ImportError("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)


from MySQLdb.converters import conversions from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE from MySQLdb.constants import FIELD_TYPE
Expand Down
6 changes: 3 additions & 3 deletions django/db/backends/mysql_old/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import MySQLdb as Database import MySQLdb as Database
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e 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
Expand Down Expand Up @@ -48,14 +48,14 @@ def execute(self, sql, params=()):
return self.cursor.execute(sql, params) return self.cursor.execute(sql, params)
except Database.Warning, w: except Database.Warning, w:
self.cursor.execute("SHOW WARNINGS") self.cursor.execute("SHOW WARNINGS")
raise Database.Warning, "%s: %s" % (w, self.cursor.fetchall()) raise Database.Warning("%s: %s" % (w, self.cursor.fetchall()))


def executemany(self, sql, param_list): def executemany(self, sql, param_list):
try: try:
return self.cursor.executemany(sql, param_list) return self.cursor.executemany(sql, param_list)
except Database.Warning, w: except Database.Warning, w:
self.cursor.execute("SHOW WARNINGS") self.cursor.execute("SHOW WARNINGS")
raise Database.Warning, "%s: %s" % (w, self.cursor.fetchall()) raise Database.Warning("%s: %s" % (w, self.cursor.fetchall()))


def __getattr__(self, attr): def __getattr__(self, attr):
if attr in self.__dict__: if attr in self.__dict__:
Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/oracle/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import cx_Oracle as Database import cx_Oracle as Database
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading cx_Oracle module: %s" % e raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)


DatabaseError = Database.Error DatabaseError = Database.Error
IntegrityError = Database.IntegrityError IntegrityError = Database.IntegrityError
Expand Down Expand Up @@ -113,9 +113,7 @@ def iterator(self):
except EmptyResultSet: except EmptyResultSet:
raise StopIteration raise StopIteration
if not full_query: if not full_query:
full_query = "SELECT %s%s\n%s" % \ full_query = "SELECT %s%s\n%s" % ((self._distinct and "DISTINCT " or ""), ', '.join(select), sql)
((self._distinct and "DISTINCT " or ""),
', '.join(select), sql)


cursor = connection.cursor() cursor = connection.cursor()
cursor.execute(full_query, params) cursor.execute(full_query, params)
Expand Down
6 changes: 3 additions & 3 deletions django/db/backends/postgresql/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import psycopg as Database import psycopg as Database
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading psycopg module: %s" % e raise ImproperlyConfigured("Error loading psycopg module: %s" % e)


DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError IntegrityError = Database.IntegrityError
Expand Down Expand Up @@ -85,7 +85,7 @@ def _cursor(self, settings):
set_tz = True set_tz = True
if settings.DATABASE_NAME == '': if settings.DATABASE_NAME == '':
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file." raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
conn_string = "dbname=%s" % settings.DATABASE_NAME conn_string = "dbname=%s" % settings.DATABASE_NAME
if settings.DATABASE_USER: if settings.DATABASE_USER:
conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string) conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string)
Expand Down Expand Up @@ -121,7 +121,7 @@ def typecast_string(s):
try: try:
Database.register_type(Database.new_type((1082,), "DATE", util.typecast_date)) Database.register_type(Database.new_type((1082,), "DATE", util.typecast_date))
except AttributeError: except AttributeError:
raise Exception, "You appear to be using psycopg version 2. Set your DATABASE_ENGINE to 'postgresql_psycopg2' instead of 'postgresql'." raise Exception("You appear to be using psycopg version 2. Set your DATABASE_ENGINE to 'postgresql_psycopg2' instead of 'postgresql'.")
Database.register_type(Database.new_type((1083,1266), "TIME", util.typecast_time)) Database.register_type(Database.new_type((1083,1266), "TIME", util.typecast_time))
Database.register_type(Database.new_type((1114,1184), "TIMESTAMP", util.typecast_timestamp)) Database.register_type(Database.new_type((1114,1184), "TIMESTAMP", util.typecast_timestamp))
Database.register_type(Database.new_type((16,), "BOOLEAN", util.typecast_boolean)) Database.register_type(Database.new_type((16,), "BOOLEAN", util.typecast_boolean))
Expand Down
4 changes: 2 additions & 2 deletions django/db/backends/postgresql_psycopg2/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import psycopg2.extensions import psycopg2.extensions
except ImportError, e: except ImportError, e:
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)


DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError IntegrityError = Database.IntegrityError
Expand Down Expand Up @@ -47,7 +47,7 @@ def _cursor(self, settings):
set_tz = True set_tz = True
if settings.DATABASE_NAME == '': if settings.DATABASE_NAME == '':
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file." raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
conn_string = "dbname=%s" % settings.DATABASE_NAME conn_string = "dbname=%s" % settings.DATABASE_NAME
if settings.DATABASE_USER: if settings.DATABASE_USER:
conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string) conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string)
Expand Down

0 comments on commit b367ec2

Please sign in to comment.