In this article, we will learn how to build Web Application with FLASK and MYSQL that have the capabilities to create, read, update, and delete data from the MYSQL database.
- Python 3
- Flask library
- pymysql library
- flask-sqlalchemy library
Please go through the following steps in order to implement Python web application CRUD example using Flask and MySQL:
Step 1. Create MySQL database table – 'employee' with the following structure.
Step 2.Create the below app.py script(py is the extension to indicate Python script) where we import the flask module.
Step 3.create the below db_config.py Python script o setup the MySQL database configurations for connecting to the database.
Step 4.Next we need 'webcontroller.py' script. This script is the perfect instance of Python Web API CRUD Example using Flask and MySQL. It defines all functions for performing CRUD operations.
Step 5. A HTML file 'view.html'
Step 8. Run the Application
Now navigate to the directory and execute the command python webcontroller.py as shown in the below image, your server will start on 8080.