Question: Hands - On Test 1 Developing a Flask Application with MySQL Database Integration Student: _ _ _ _ _ _ _ _ _ _ _
HandsOn Test Developing a Flask Application with MySQL Database Integration
Student:
Due Date: Week
Purpose: The purpose of this HandsOn test is to:
Develop a Flask application that interacts with a MySQL database Community Edition
Implement CRUD operations.
References: Read the courses text chapters and the lecture tutorials. This material provides the necessary information that you need to complete the exercises.
Be sure to read the following general instructions carefully:
This assignment must be completed individually by all the students.
You will have to demonstrate your solution in a scheduled lab session and upload the solution on eCentennial through the assignment link.
Exercise #: Basic Flask App with CRUD Operations
In this exercise, you will develop a simplified Flask application that interacts with a MySQL database. You will implement basic two of the CRUD Create Read, Update, Delete operations for a single table, focusing on understanding the integration between a Flask application and a MySQL database.
Tasks
Environment Setup:
Ensure Flask and FlaskSQLAlchemy are installed in your Flask environment.
Database Configuration and Model Creation:
Configure your Flask app to connect to a MySQL database. Use a simplified database schema with a single table for demonstration.
Define a simple model in Flask to mirror an entity in your MySQL database. For instance, create a Device model with fields: id name, type, and status.
CRUD Operations:
Implement CRUD operations in Flask, interacting with the MySQL database for the Device model. Focus on the following operations:
Create: Add new devices.
Read: View device details.
Update: Modify device information.
Delete: Remove devices.
Simple Flask View Functions:
Create basic routes and views in Flask for each CRUD operation.
Utilize Flask forms for data entry and basic Jinja templates for displaying data. Ensure simplicity for time efficiency.
Simplifications:
Omit detailed environment and MySQL database setup instructions. Assume students have a preconfigured environment.
Reduce the database schema complexity by focusing on a single table Device and excluding relationships.
Simplify frontend development requirements by not mandating extensive styling or complex user interface designs. Focus on functionality over aesthetics.
Exclude advanced Flask extensions like FlaskMigrate for this exercise due to time constraints.
Database Context: Device Management
Database Table: Device
Fields:
o id Primary Key, Integer, Auto Increment
o name Varchar
o type Varchar eg Router, Switch
o status Varchar eg Active, Inactive Comment on the code per section in detail. Eg:
aThis section is to define the DB MySQL
bHere I am defining the models which are going to be for each table.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
