How to connect to the database using python?
Try pysql if you are using a mysql database. I'll assume you are. https://pypi.python.org/pypi/PyMySQL
Another would be pymssql which works well for MSSQL
most applications use a python framework, such as Django...it has several classes and methods for web, including secure data manipulation. trying to do it all by hand with standard python can be tricky, as security flaws sometimes never show as errors, just code that should be written differently.