Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find Informix sqlhosts at None #7

Open
1 task
AcckiyGerman opened this issue Nov 30, 2018 · 1 comment
Open
1 task

Cannot find Informix sqlhosts at None #7

AcckiyGerman opened this issue Nov 30, 2018 · 1 comment

Comments

@AcckiyGerman
Copy link

AcckiyGerman commented Nov 30, 2018

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.

@AcckiyGerman
Copy link
Author

ATM I've fixed issue locally by adding

# fix connection to Informix odbc:
os.environ['INFORMIXSQLHOSTS'] = '/usr/informix/etc/sqlhosts'
os.environ['DB_LOCALE'] = 'de_DE.8859-15'

DATABASES = { ...

in my settings.py file, but it is a non-obvious workaround, not a clean solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant