What should be my configuration to load pyodbc module on Apache Server to run simple queries mssql server database

后端 未结 1 1009
青春惊慌失措
青春惊慌失措 2021-01-29 04:42

As I\'m new to python.

I need to know simple database connectivity with Apache HTTP Server.

Just I need to run the below code in Apache HTTP Server.



        
相关标签:
1条回答
  • 2021-01-29 05:28

    You're missing several layers to your stack, which are really good ideas to learn and use if you want to leverage pyodbc:

    • Apache (installed) mod_wsgi (WSGI is a specification that describes how a web server communicates with web applications)
    • A framework to protect you from very bad things happening

    However, if all you want is for that to appear on a web page, you can do it as a CGI program. This is a bad idea, but is quick and dirty.

    You'll need to add this before any output (before for row):

    print("Content-Type: text/html;charset=utf-8")
    print()
    

    And then follow these instructions to configure Apache to run your Python script: https://www.linux.com/blog/configuring-apache2-run-python-scripts

    0 讨论(0)
提交回复
热议问题