""" $Id$ IBM DB2 database backend for Django Requires PyDB2: http://sourceforge.net/projects/pydb2/ With this patch: http://sourceforge.net/tracker/index.php?func=detail&aid=1731609&group_id=67548&atid=518208 """ from django.db.backends import util import re try: import DB2 as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading DB2 python module: %s" % e DatabaseError = Database.Error IntegrityError = Database.IntegrityError class Cursor(Database.Cursor): """ PyDB2 uses '?' as the parameter style. """ def execute(self, stmt, *args): # TODO: HORRIBLE hacks. if stmt.find('CREATE') == 0: # DB2 doesn't want a 'lone' NULL (it's implied). stmt = re.sub('(? %s", 'gte': ">= %s", 'lt': "< %s", 'lte': "<= %s", 'startswith': "LIKE %s", 'endswith': "LIKE %s", 'istartswith': "LIKE %s", 'iendswith': "LIKE %s", }