问题描述
将cmd执行为 c:\> pip install pyodbc
将创建" pyodbc.cp36-win32.pyd "文件
Executing the cmd as c:\>pip install pyodbc
"pyodbc.cp36-win32.pyd" file will be created
Collecting pyodbc Using cached
pyodbc-4.0.21-cp36-cp36m-win32.whl Installing collected packages:
pyodbc Successfully installed pyodbc-4.0.21
当我尝试在Apache24 Server中运行时,以下代码会导致内部服务器错误
When I try to run in Apache24 Server the below code results in Internal Server Error
import pyodbc
cnxn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};"
"Server=DESKTOP;"
"Database=demo2017;"
"Trusted_Connection=yes;")
cursor = cnxn.cursor()
cursor.execute('SELECT * FROM Table')
for row in cursor:
print('row = %r' % (row,))
在python shell中作为
运行 C:\ Apache24 \ htdocs> python mssql_odbc.py
结果将正常显示.但不是在Apache http服务器上.
Running in python shell as
C:\Apache24\htdocs>python mssql_odbc.py
Results will be displayed fine. But not at apache http server.
在httpd.conf文件中:
In httpd.conf file:
LoadModule pyodbc_module "c:/users/desktop/appdata/local/programs/python/python36-32/lib/site-packages/pyodbc.cp36-win32.pyd"
结果
httpd: Syntax error on line 571 of C:/Apache24/conf/httpd.conf: Can't
locate API module structure `pyodbc_module' in file
C:/Users/Desktop/AppData/Local/Programs/Python/Python36-32/Lib/site-packages/pyodbc.cp36-win32.pyd:
No error
那么,是否应该导入/修改任何模块或代码?
So are there any modules or code that should be imported/modified?
推荐答案
在Apache 已解决500个内部错误 中.由于 导入pypyodbc 而不是 import pyodbc .
In Apache 500 Internal Error Solved. Because of importing pypyodbc instead of import pyodbc.
在python shell中,我能够成功连接到 python shell 和 Database 中.
In python shell I was able to connect successfully retrive the results in python shell as well as in Database.
这篇关于在Apache HTTP Server中将pyodbc结果导入为内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!