-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
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
$INFORMIXSQLHOSTSis Setsqlhostsfile 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
sqlhostsfile in thedjango.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.
- see Readme update: DB_LOCALE env & its explanation. #6 , where I had to set
$DB_LOCALE, which could be different for each DB.
- see Readme update: DB_LOCALE env & its explanation. #6 , where I had to set
- 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
Labels
No labels