Getting started with IBM DB Django adapterIBM Dataservers backend support in Django application Framework. ibm_db_django enables access to IBM databases from Django applications http://www.djangoproject.com/ The adapter has been developed and is supported by IBM. Prerequisites- Python 2.5.
- Django Framework 1.0.x or above.
- IBM_DB driver and IBM_DB_DBI wrapper 0.7.2.5 or higher (ibm_db-0.7.2.5 is a minimum UCS-2 support, ibm_db-1.0 is minimum for UCS-4 support)
Updation from from ibm_db_django-0.1.0 to ibm_db_django-0.1.2Django 1.1 and ibm_db_django support The name of the adaptor (in Django terminology, the DATABASE_ENGINE) has been changed to 'ibm_db_django' from this version onwards (in earlier versions it was 'db2'). For your existing apps please remember to change this once you upgrade to ibm_db_django-0.1.2 The 'DATABASE_ENGINE' field in settings.py should as below when using ibm_db_django-0.1.2 DATABASE_ENGINE = 'ibm_db_django'
(In version 0.1.0, it is "DATABASE_ENGINE = 'db2' " ) Install DjangoInstall Django as per instructions from the Django website. DB2 Django adapter (ibm_db_django) Build and InstallationDownload latest release of ibm_db_django from official release Install Django as per instructions from the Django website (http://docs.djangoproject.com/en/dev/topics/install/#installing-an-official-release) 1. Linux/MAC $ easy_install ibm_db_django-0.1.2.egg
2. Windows c:\> easy_install ibm_db_django-0.1.2.egg
or Install from PyPi $ easy_install ibm_db
Tested Operating Systems- Ubuntu Linux 7.04 32 bit
- Windows XP 32 bit
- Mac OS X Leopard
Supported DatabasesIBM DB2 Database for Linux, Unix, Windows and MAC OS X, version 8.2 or higher (9.5 FP2 or higher for MAC OS X). Future Supported Databases- IBM Cloudscape
- Apache Derby
- Informix(IDS) Cheetah version 11.10 onwards
- Remote connections to i5/OS (iSeries)
- Remote connections to z/OS (DB2 UDB for zOS)
Testing- 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): DATABASE_ENGINE = 'ibm_db_django'
DATABASE_NAME = 'mydb'
DATABASE_USER = 'db2inst1'
DATABASE_PASSWORD = 'ibmdb2'
DATABASE_HOST = 'localhost'
DATABASE_PORT = '50000' 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 Windows, steps are same as above. In case of editing settings.py file, use notepad (or any other) editor. Known Limitations of ibm_db_django adapter- User needs to create test database. It can not be created by this adapter.
- Test cases related to NULLs in UNIQUE columns will fail. (Not supported by DB2)
- Support for REGEX lookup is not present yet.
- Non-standard SQL queries are not supported. e.g. "SELECT ? FROM TAB1"
- EXACT lookup for LOB fields do not work. (Not supported by DB2)
- CASE in-sensitive search in case of NUMBER datatypes (INT, FLOAT, DECIMAL, etc.) do not work (Not supported by DB2)
- If values are inserted/updated manually in Auto Field, then the adapter will fail if auto increment is done again on this Auto Field.
- 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.
- Decimal datatype is not yet supported by driver, thus the following sample or likewise would fail with Binding Error
Foo.objects.create(id=1, name='abc', dval = Decimal("12.34"))DB2 Timestamps do not support timezone aware information. Thus a Datetime field including tzinfo(timezone aware info) would fail. Feedback
|