Answered step by step
Verified Expert Solution
Question
1 Approved Answer
LAB Assignment 2 Developing a Flask Application with MySQL Database Integration Student: _ _ _ _ _ _ _ _ _ _ _ _ _
LAB Assignment Developing a Flask Application with MySQL Database Integration
Student:
Due Date: Sunday of Week
Purpose: The purpose of this Lab assignment is to:
Develop a Flask application that interacts with a MySQL database Community Edition
Implement CRUD operations.
References: Read the courses text chapter 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 #: Simple Flask App
In this exercise you will create a Flask application that connects to a MySQL database to add, view, update, and delete data, demonstrating a fundamental understanding of database integration in web applications.
Tasks
Environment and MySQL Database Setup:
a Install MySQL Community Edition and set it up on your local machine.
b Ensure Flask, FlaskSQLAlchemy, and FlaskMigrate are installed in your Flask environment.
Database Configuration in Flask:
a Configure the Flask app to connect to the MySQL database.
b Set up the database URI in the Flask configuration to use MySQL
Model Creation and Relationships:
a Define models in Flask to mirror the entities in your MySQL database eg User, Post, Product
b Establish relationships between models onetomany, manytomany, etc.
Implementing Database Migrations:
a Use FlaskMigrate to handle migrations for the MySQL database.
b Create and apply migration scripts for initial database setup and any subsequent schema changes.
CRUD Operations:
a Implement CRUD operations in Flask, interacting with the MySQL database.
b Test database operations Create Read, Update, Delete to ensure they work as expected.
Integrating CRUD Operations with Flask View Functions:
a Create routes and views in Flask for each CRUD operation.
b Design and implement forms for data entry and templates for data display.
FrontEnd Development:
a Develop a userfriendly interface with Jinja templates.
b Ensure forms and tables are properly formatted and styled.
Database Context: Network Device Management
o Database Name: networkmanagementdb
Tables and Descriptions:
o Table: devices
Description: Contains details about network devices managed by the system.
Fields:
deviceid Primary Key, Integer, Auto Increment
devicename Varchar
ipaddress Varchar Unique
devicetype Varchar eg Router, Switch, Firewall
location Varchar
status Varchar eg Active, Inactive, Under Maintenance
o Table: networklogs
Description: Stores logs of network events or changes.
Fields:
logid Primary Key, Integer, Auto Increment
deviceid Integer Foreign Key to devices.deviceid
timestamp DateTime
logdescription Text
o Table: maintenancerecords
Description: Records maintenance activities for each device.
Fields:
recordid Primary Key, Integer, Auto Increment
deviceid Integer Foreign Key to devices.deviceid
maintenancedate Date
details Text
technicianname Varchar
o Table: users
o Description: Contains user accounts who can access or modify the network device data.
o Fields:
userid Primary Key, Integer, Auto Increment
username Varchar Unique
passwordhash Varchar
role Varchar eg Admin, Technician, Viewer
email Varchar Unique
o Relationships:
devices to networklogs: OnetoMany One device can have multiple logs
devices to maintenancerecords: OnetoMany One device can have multiple maintenance records
CRUD Operations Examples:
o Create: Add new network devices, log entries, maintenance records, or users.
o Read: View device details, logs maintenance history, or user profiles.
o Update: Modify device information, update maintenance records, or change user roles.
o Delete: Remove devices, logs maintenance records, or user accounts.
marks
Evaluation Criteria:
Functionality: All features must work correctly with the MySQL database.
Database Integration: Effective use of FlaskSQLAlchemy and FlaskMigrate with MySQL
FrontEnd: All forms and pages
Code Quality: Code should be clean, wellorganized, and commented, following Python standards.
Friendliness of UI: The web interface should be intuitive and userfriendly.
Total
You must name your VS or PyCharm Code project according to the following rule:
yourfullnameSWSLabnumberExercisenumber.
Example: JohnSmithSWSLabEx
Submission rules:
Submit the VS Code project named according to the following rule:
yourfullnameSWSLabnumberExercisenumber.zip
Example: JohnSmithSWSLabExzip
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started