Django AS400/DB2 Compatibility

639 views
Skip to first unread message

erik_says

unread,
Feb 23, 2016, 1:39:56 AM2/23/16
to ibm_db
I am having trouble configuring a Django database connection to a DB2/AS400 server. I am not sure if I have a configuration error or if the versions of python/django I am using are simply incompatible. The documentation says Django > 1.7.x, but also python 2.7...but this question shows someone using it with Python 3.3.1.

Python: 3.4.3
Django: 1.9.2
ibm-db: 2.0.6
ibm-db-django: 1.0.7

DATABASES = {
'as400': {
'ENGINE': 'ibm_db_django',
'NAME': 'as400',
'USER': '<Valid Username>',
'PASSWORD': <Valid Password>,
'HOST': '<Valid IP Address>',
'PORT' : '50000',
'PCONNECT': True,
}
}

This is the error:

/home/programming/workspace/DjangoProjects/venv/bin/python3.4 /home/programming/workspace/DjangoProjects/mohawkapi/manage.py runserver 127.0.0.1:8000
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f5fc3b8ce18>
Traceback (most recent call last):
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/db/utils.py", line 116, in load_backend
    return import_module('%s.base' % backend_name)
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/ibm_db_django/base.py", line 29, in <module>
    from django.db.backends import BaseDatabaseFeatures
ImportError: cannot import name 'BaseDatabaseFeatures'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/db/models/base.py", line 1172, in check
    errors.extend(cls._check_long_column_names())
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/db/models/base.py", line 1587, in _check_long_column_names
    connection = connections[db]
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/db/utils.py", line 212, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/programming/workspace/DjangoProjects/venv/lib/python3.4/site-packages/django/db/utils.py", line 135, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'ibm_db_django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: cannot import name 'BaseDatabaseFeatures'

Jose Paul

unread,
Feb 23, 2016, 2:37:41 AM2/23/16
to ibm...@googlegroups.com
I suggest get the latest code from git .

Please uninstall before doing it .

Also install DJango 1.8 instead of 1.9



--
You received this message because you are subscribed to the Google Groups "ibm_db" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibm_db+un...@googlegroups.com.
To post to this group, send email to ibm...@googlegroups.com.
Visit this group at https://groups.google.com/group/ibm_db.
For more options, visit https://groups.google.com/d/optout.

erik_says

unread,
Feb 23, 2016, 11:33:20 PM2/23/16
to ibm_db
Thank you for the help, working now. Downgrading to Django 1.8.6 and manually installing ibm_db_django 1.0.9 worked. I'm not sure if it was my error but using pip3 to install ibm_db_django installed 1.0.7.
Reply all
Reply to author
Forward
0 new messages