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.
You're missing several layers to your stack, which are really good ideas to learn and use if you want to leverage pyodbc
:
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