执行 cmd 作为 c:\>pip install pyodbc
" pyodbc.cp36-win32.pyd " 文件将被创建
Collecting pyodbc Using cached pyodbc-4.0.21-cp36-cp36m-win32.whl Installing collected packages: pyodbc Successfully installed pyodbc-4.0.21
当我尝试在 Apache24 服务器中运行时,以下代码导致内部服务器错误
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 服务器上。
在 httpd.conf 文件中:
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
那么是否有任何应该导入/修改的模块或代码?