【发布时间】:2018-04-10 00:42:09
【问题描述】:
我有一个 Django 网站,它使用 TURBODBC 在旧数据库上执行一些直接 SQL 调用。这在使用内置 django 测试服务器时非常有效,但是当我使用 Apache2 运行它时,我收到错误消息:“ODBC 错误状态:60”。我觉得它与使用 mod_wsgi 运行它有关,但我不确定。我对谷歌没有运气。甚至不确定“状态:60”是什么意思。
Internal Server Error: /inventory/in/
[Mon Apr 09 22:01:09.718077 2018] [wsgi:error] [pid 10074:tid 140709839501056] Traceback (most recent call last):
[Mon Apr 09 22:01:09.718147 2018] [wsgi:error] [pid 10074:tid 140709839501056] File "/usr/local/lib/python3.5/dist-packages/turbodbc/exceptions.py", line 50, in wrapper
[Mon Apr 09 22:01:09.718213 2018] [wsgi:error] [pid 10074:tid 140709839501056] return f(*args, **kwds)
[Mon Apr 09 22:01:09.718282 2018] [wsgi:error] [pid 10074:tid 140709839501056] File "/usr/local/lib/python3.5/dist-packages/turbodbc/connect.py", line 44, in connect
[Mon Apr 09 22:01:09.718347 2018] [wsgi:error] [pid 10074:tid 140709839501056] turbodbc_options))
[Mon Apr 09 22:01:09.718410 2018] [wsgi:error] [pid 10074:tid 140709839501056] turbodbc_intern.Error: ODBC error
[Mon Apr 09 22:01:09.718493 2018] [wsgi:error] [pid 10074:tid 140709839501056] ] state: 60
问题: “状态 60”是什么意思? 是什么导致了这个错误? 我该如何纠正这个问题?
重现错误的简单程序。
from turbodbc import connect
def application(environ, start_response):
status = '200 OK'
output = b'Hello World!'
connect_to_db()
response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
def connect_to_db():
connection = connect(dsn="odbc-dev", uid='foo', pwd='bar')
cursor = connection.cursor()
apache2 配置:
WSGIScriptAlias / /srcPython3/wsgi_test/hello_world.py
WSGIPythonPath /srcPython3/wsgi_test/
<VirtualHost *:80>
<Directory /srcPython3/wsgi_test>
<Files hello_world.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
错误日志
mod_wsgi (pid=11944): Exception occurred processing WSGI script '/srcPython3/wsgi_test/hello_world.py'.
[wsgi:error] Traceback (most recent call last):
[wsgi:error] File "/usr/local/lib/python3.5/dist-packages/turbodbc/exceptions.py", line 50, in wrapper
[wsgi:error] return f(*args, **kwds)
[wsgi:error] File "/usr/local/lib/python3.5/dist-packages/turbodbc/connect.py", line 44, in connect
[wsgi:error] turbodbc_options))
[wsgi:error] turbodbc_intern.Error: ODBC error
[wsgi:error] state: 60
[wsgi:error]
[wsgi:error] During handling of the above exception, another exception occurred:
[wsgi:error]
[wsgi:error] Traceback (most recent call last):
[wsgi:error] File "/srcPython3/wsgi_test/hello_world.py", line 7, in application
[wsgi:error] connect_to_db()
[wsgi:error] File "/srcPython3/wsgi_test/hello_world.py", line 15, in connect_to_db
[wsgi:error] connection = connect(dsn="odbc-dev", uid='foo', pwd='bar')
[wsgi:error] File "/usr/local/lib/python3.5/dist-packages/turbodbc/exceptions.py", line 52, in wrapper
[wsgi:error] raise DatabaseError(str(e))
[wsgi:error] turbodbc.exceptions.DatabaseError: ODBC error
[wsgi:error] state: 60
谢谢
【问题讨论】:
-
如果你在这里没有得到答案,你应该在github.com/blue-yonder/turbodbc提出一个问题
标签: django python-3.x odbc apache2 mod-wsgi