Skip to content

Cannot find Informix sqlhosts at None #7

@AcckiyGerman

Description

@AcckiyGerman

Error: Cannot find Informix sqlhosts at None

.../lib/python3.6/site-packages/django_informixdb/base.py in get_connection_params, line 192

Environment:

  • Ubuntu 16.04.02
  • Apache 2.4.18
  • mod_wsgi 4.6.5
  • Django 2.1.3
  • Python 3.6.7
  • $INFORMIXSQLHOSTS is Set
  • sqlhosts file is correct.

Analysis

Connection to Informix works, when project hosted by django dev server: ./manage.py runserver; but under Apache it doesn't.

My Idea is that Apache runs the project in a separate thread, hiding the host env.vars for the security purposes, so django_informixdb can't reach $INFORMIXSQLHOSTS

Possible solutions:

  • Set path to sqlhosts file in the django.settings.DATABASES

Generally I think that all the variables for django_informixdb should be in django.settings.DATABASES, instead of getting them from environment.
In that case:

  • information is explicitly described
  • could be stored in git/svn/etc
  • user could use different variables to connect for several Informix servers.
  • easier to deploy project in different platforms (docker, windows, RHAT, etc) where environment vars are managed in a different ways

If the developer wants to be more flexible and use envars instead of hardcoding, he could use os.environ:

DATABASES = {
    'default': {
        ...
        'OPTIONS': {
             'DRIVER': os.path.join(os.environ['INFORMIXBIN'], 'lib/iclit09b.so'),
             'INFORMIXSQLHOSTS': os.environ['INFORMIXSQLHOSTS'],
             'DB_LOCALE': os.environ['DB_LOCALE']

        }
    }
}

But information is still explicit and anybody could understand, where is it taken from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions