Question: Hands - On Test 1 Developing a Flask Application with MySQL Database Integration Student: _ _ _ _ _ _ _ _ _ _ _

Hands-On Test 1 Developing a Flask Application with MySQL Database Integration
Student: ______________________
Due Date: Week 7
Purpose: The purpose of this Hands-On test is to:
Develop a Flask application that interacts with a MySQL database (Community Edition)
Implement CRUD operations.
References: Read the courses text chapters 5-6 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 #1: 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
1. Environment Setup:
Ensure Flask and Flask-SQLAlchemy are installed in your Flask environment.
2. 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.
3. 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.
4. Simple Flask View Functions:
Create basic routes and views in Flask for each CRUD operation.
Utilize Flask forms for data entry and basic Jinja2 templates for displaying data. Ensure simplicity for time efficiency.
5. Simplifications:
Omit detailed environment and MySQL database setup instructions. Assume students have a pre-configured environment.
Reduce the database schema complexity by focusing on a single table (Device) and excluding relationships.
Simplify front-end development requirements by not mandating extensive styling or complex user interface designs. Focus on functionality over aesthetics.
Exclude advanced Flask extensions like Flask-Migrate for this exercise due to time constraints.
6. Database Context: Device Management
Database Table: Device
Fields:
o id (Primary Key, Integer, Auto Increment)
o name (Varchar)
o type (Varchar) e.g., Router, Switch
o status (Varchar) e.g., Active, Inactive7. Comment on the code per section in detail. E.g:
a)This section is to define the DB MySQL.
b)Here 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!