> On 7 Oct 2016, at 4:31 AM, Varun <[email protected]> wrote:
>
> Mine was Flask Application running under Apache 2.4 ( which was installed
> manually ) and mod_wsgi in Linux RHEL 6.
>
> I had installed ODBC driver and changed the perimissions of .ini files to
> chmod 777 and owner group of files to root. So Pyodbc connection works fine
> on Python Shell and causing problem while running under Apache.
>
> Error Message:
>
> Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not
> found, and no default driver specified (0) (SQLDriverConnect)')
>
>
> Earlier I was using bashrc file to export the environment variables and
> those working fine for Oracle drivers and others. But Even after adding to
> bashrc the connection raises an error for pyodbc. Don't know the reason.
>
> I had tried setting it up in the Wsgi Script using os.putenv(). But still
> hadn't helped.
You shouldn’t use os.putenv() as that doesn’t update os.environ so if any code
is expecting to find the environment variable in normal place it will not.
>>> import os
>>> os.putenv('XXX', 'YYY')
>>> os.environ['XXX']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py",
line 23, in __getitem__
raise KeyError(key)
KeyError: 'XXX'
You should use:
os.environ[‘XXX’] = ‘YYY’
to set environment variables from the WSGI script file.
Give that a try instead.
Graham
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.