-
Notifications
You must be signed in to change notification settings - Fork 194
ibm_db_django_README
IBM DB2 support for the Django application Framework.
ibm_db_django enables access to IBM DB2 from Django applications http://www.djangoproject.com/
The adapter has been developed and is supported by IBM.
- Python 2.5.
- Django Framework 1.0.x or above.
- IBM_DB driver and IBM_DB_DBI wrapper 1.0 or higher
We are assuming that you have IBM DB2 installed. If you need to connect from Django to a DB2 server on the same local machine, just proceed to the Install steps below. If you need to connect from Django to a DB2 server on different machine, then you will need to at minimum install the IBM Data Server Driver Package on the machine where you install Django.
- Jython-2.5
- Django Framework 1.0.x or 1.1.x
- IBM DB2 JDBC Driver (db2jcc.jar) on CLASSPATH
Install Django as per instructions from the Django website.
- For 1.0.2, you need to apply a patch in django in-order to remove Non-standard SQL generation issue.
- The patch is located at http://code.djangoproject.com/ticket/9862.
- You can extract creation.py file from http://code.djangoproject.com/changeset/9703?format=zip&new=9703 and paste it to /django/db/backends/
- For versions greater than 1.0.2 no patch is required.
Download latest release of ibm_db_django from official release
To install DB2 Django adapter on Linux
$ easy_install ibm_db_django
To install DB2 Django adapter on Windows
c:> easy_install ibm_db_django
- Ubuntu Linux 7.04 64 bit
- Windows XP 32 bit
- IBM DB2 Database for Linux, Unix and Windows, version 8.2 or higher.
- Remote connections to z/OS (DB2 UDB for zOS)
- IBM Cloudscape
- Apache Derby
- IBM Informix Cheetah version 11.10 onwards
- Remote connections to i5/OS (iSeries)
Note for Django on Python: Before you run Django to connect to DB2, you need to ensure that IBM CLI (which the DB2 Django adapter uses to connect to DB2) is accessible from Django. On Linux, set the LD_LIBRARY_PATH variable (for the user executing Django) to include the folder where the IBM CLI shared library (libdb2.so) resides -
for local DB2 access: export LD_LIBRARY_PATH=<
DB2_HOME>
/sqllib/lib:$LD_LIBRARY_PATH .
for remote DB2 access with DS Driver: export LD_LIBRARY_PATH=<
DS_DRIVER_FOLDER>
/odbc_cli_driver/linux/clidriver/lib:$LD_LIBRARY_PATH
- Create a new Django project by executing "django-admin.py startproject myproj".
- Now go to this newly create directory, and edit settings.py file to access DB2.
- In case of nix the steps will be like:
$ django-admin.py startproject myproj
$ cd myproj
$ vi settings.py
- The settings.py will be like (after adding DB2 properties):
DATABASES = {
'default': {
'ENGINE' : 'ibm_db_django',
'NAME' : 'mydb',
'USER' : 'db2inst1',
'PASSWORD' : 'ibmdb2',
'HOST' : 'localhost',
'PORT' : '50000',
'PCONNECT' : True, #Optional property, default is false
}
}
- To enable DB2 support you need to set value of DATABASE_ENGINE to 'ibm_db_django' in settings.py.
- In the tuple INSTALLED_APPS in settings.py add the following lines:
'django.contrib.flatpages',
'django.contrib.redirects',
'django.contrib.comments',
'django.contrib.admin',
- Next step is to run a simple test suite. To do this just execute following command in the project we created earlier:
$ python manage.py test #for Django-1.5.x or older
$ Python manage.py test django.contrib.auth #For Django-1.6.x onwards, since test discovery behavior have changed
- For Windows, steps are same as above. In case of editing settings.py file, use notepad (or any other) editor.
- Django by default executes without transactions i.e. in auto-commit mode. This default is generally not what you want in web-applications. Remember to turn on transaction support in Django
- Non-standard SQL queries are not supported. e.g. "SELECT ? FROM TAB1"
- dbshell will not work if server is remote and client is DB2 thin client.
- For updations involving primary/foreign key references, the entries should be made in correct order. Integrity check is always on and thus the primary keys referenced by the foreign keys in the referencing tables should always exist in the parent table.
- DB2 Timestamps do not support timezone aware information. Thus a Datetime field including tzinfo(timezone aware info) would fail.
- ibm-db_django wiki: http://code.google.com/p/ibm-db/wiki/ibm_db_django_README
- ibm-db issues reports: http://code.google.com/p/ibm-db/issues/list
- ibm-db developers: opendev@us.ibm.com