Posts

Showing posts with the label Flask

USER MANAGEMENT USING FLASK FRAMEWORK AND MySQL DATABASE IN PYTHON

Image
Package Installation :   pip install flask pip install flask-mysqldb Program : # User Management in python using Flask framework and MySQL Database from flask import Flask , render_template , url_for , request , redirect , flash from flask_mysqldb import MySQL app = Flask(__name__) # This takes the filename as a parameter # MySQL Connection app.config[ "MYSQL_HOST" ] = "localhost" app.config[ "MYSQL_USER" ] = "root" # Database Username app.config[ "MYSQL_PASSWORD" ] = "Enter the password" # Database Password app.config[ "MYSQL_DB" ] = "crud" # Database Name app.config[ "MYSQL_CURSORCLASS" ] = "DictCursor" mysql = MySQL(app) # Loading Home Page @app.route ( "/" ) # Home Page def home (): cursor = mysql.connection.cursor() # SELECT Query query = "SELECT * FROM users" cursor.execute(query) result = cursor.fetchall() return render_template...