Importing pyodbc results as Internal server error in Apache HTTP Server

≡放荡痞女 提交于 2019-12-11 14:06:41

问题


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


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,)) 

Running in python shell as
C:\Apache24\htdocs>python mssql_odbc.py
Results will be displayed fine. But not at apache http server.

In httpd.conf file:

 LoadModule pyodbc_module "c:/users/desktop/appdata/local/programs/python/python36-32/lib/site-packages/pyodbc.cp36-win32.pyd"

Results

 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?


回答1:


In Apache 500 Internal Error Solved. Because of importing pypyodbc instead of import pyodbc.

In python shell I was able to connect successfully retrive the results in python shell as well as in Database.




来源:https://stackoverflow.com/questions/47571249/importing-pyodbc-results-as-internal-server-error-in-apache-http-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!