Skip to content

Commit 28a29ee

Browse files
committed
Initial commit
0 parents  commit 28a29ee

File tree

1,011 files changed

+306218
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,011 files changed

+306218
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

galipeau-aaron-week-5/.DS_Store

6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "${workspaceFolder}/venv/bin/python.exe"
3+
}

galipeau-aaron-week-5/LICENSE.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Educational License
2+
3+
This project is licensed under the Educational License for the purposes of learning, academic exercises, and research.
4+
5+
Holder:
6+
Aaron Galipeau
7+
M.S. Computer Science Student
8+
Merrimack College
9+
Lecturer: Robert Sands
10+
Course: CSC6302 Database Principles
11+
12+
This license allows the project to be used, modified, and shared for educational purposes only. Commercial use or redistribution is strictly prohibited without prior written permission.

galipeau-aaron-week-5/README.md

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
# CSC6302 Week 5 Project - Student Database with Toga GUI
3+
4+
This project is a student database application built using Python and Toga GUI. It allows users to manage student records, including displaying student information, adding new students, and calculating average grades from multiple tables in a relational database. The project integrates a business logic layer (BLL) with a data access layer (DAL) and a MySQL backend database.
5+
6+
## Features
7+
8+
- View all students along with their class subjects, grades, teacher names, and average grade.
9+
- Add new students via the Toga GUI.
10+
- Simple MySQL integration for data storage.
11+
- Custom SQL procedures for student data manipulation.
12+
13+
## Prerequisites
14+
15+
Make sure you have the following installed on your system:
16+
17+
- Python 3.10+
18+
- MySQL Server 9.0 or later
19+
20+
## Project Structure
21+
22+
```
23+
Grandparent Directory: GitHub
24+
|-- ./.DS_Store
25+
|-- ./application
26+
|-- ./application/.DS_Store
27+
|-- ./application/clean.py
28+
|-- ./application/BLL
29+
|-- ./application/BLL/students.py
30+
|-- ./application/requirements.txt
31+
|-- ./application/Makefile
32+
|-- ./application/README.md
33+
|-- ./application/Connection.py
34+
|-- ./application/VIEW
35+
|-- ./application/VIEW/.DS_Store
36+
|-- ./application/VIEW/view.py
37+
|-- ./application/DAL
38+
|-- ./application/DAL/teacherDAL.py
39+
|-- ./application/DAL/classesDAL.py
40+
|-- ./application/DAL/studentDAL.py
41+
|-- ./application/main.py
42+
|-- ./application/python-path.txt
43+
|-- ./.vscode
44+
|-- ./.vscode/settings.json
45+
|-- ./togavenv
46+
|-- ./togavenv/.DS_Store
47+
|-- ./togavenv/bin
48+
|-- ./togavenv/include
49+
|-- ./togavenv/pyvenv.cfg
50+
|-- ./togavenv/lib
51+
|-- ./togavenv/share
52+
|-- ./sql
53+
|-- ./sql/users.sql
54+
|-- ./sql/ddl.sql
55+
|-- ./sql/procedure_functions.sql
56+
|-- ./sql/query.sql
57+
|-- ./sql/dml.sql
58+
|-- ./sql/permissions.sql
59+
```
60+
61+
## Installation and Setup
62+
63+
1. **Clone the Repository**
64+
```bash
65+
git clone https://github.com/yourusername/database_principles_csc6302.git
66+
cd database_principles_csc6302
67+
```
68+
69+
2. **Create a Virtual Environment**
70+
```bash
71+
python3 -m venv togavenv
72+
source togavenv/bin/activate # On Windows use `togavenv\Scripts\activate`
73+
```
74+
75+
3. **Install Required Packages**
76+
```bash
77+
pip install -r application/requirements.txt
78+
```
79+
80+
4. **MySQL Database Setup**
81+
- Ensure that MySQL is installed and running.
82+
- Execute the SQL scripts in the `sql/` directory to create tables, add procedures, and insert sample data.
83+
84+
```bash
85+
mysql -u admin_user -p < sql/ddl.sql
86+
mysql -u admin_user -p < sql/procedure_functions.sql
87+
mysql -u admin_user -p < sql/dml.sql
88+
```
89+
90+
## Running the Application
91+
92+
1. **Start the Toga GUI**
93+
```bash
94+
python3 application/main.py
95+
```
96+
97+
This will open the GUI window for the student database management application.
98+
99+
2. **Add a Student**
100+
- Fill out the form on the right panel of the GUI to add a new student.
101+
- Click "Add User" to submit the form.
102+
- The data table on the left will refresh to display the updated list of students.
103+
104+
## Makefile Commands
105+
106+
The `Makefile` includes a convenient command for cleaning up cache files:
107+
108+
- **Clean Cache Files**
109+
```bash
110+
make clean
111+
```
112+
This command will remove all `__pycache__` files and `.DS_Store` files from the project.
113+
114+
## License
115+
116+
Educational License
117+
118+
This project is licensed under the Educational License for the purposes of learning, academic exercises, and research.
119+
120+
Holder:
121+
Aaron Galipeau
122+
M.S. Computer Science Student
123+
Merrimack College
124+
Lecturer: Robert Sands
125+
Course: CSC6302 Database Principles
126+
127+
This license allows the project to be used, modified, and shared for educational purposes only. Commercial use or redistribution is strictly prohibited without prior written permission.
6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# BLL/students.py
2+
from DAL.studentDAL import StudentDAL
3+
from DAL.teacherDAL import TeacherDAL
4+
from DAL.classesDAL import ClassesDAL
5+
6+
# Student Class
7+
class Student:
8+
"""
9+
The Student class represents a student entity and provides methods to interact with the student data.
10+
Attributes:
11+
id (int, optional): The unique identifier for the student.
12+
first_name (str, optional): The first name of the student.
13+
last_name (str, optional): The last name of the student.
14+
email (str, optional): The email address of the student.
15+
date_of_birth (str, optional): The date of birth of the student.
16+
grade (str, optional): The grade of the student.
17+
Methods:
18+
add():
19+
Adds a new student record using a stored procedure.
20+
read():
21+
Reads the student record based on the student's ID.
22+
getStudents():
23+
Retrieves all student records.
24+
getStudentsWithClasses():
25+
Retrieves all student records along with their associated classes.
26+
"""
27+
def __init__(self, id=None, first_name=None, last_name=None, email=None, date_of_birth=None, grade=None):
28+
"""
29+
Initializes a new instance of the Student class.
30+
31+
Args:
32+
id (int, optional): The unique identifier for the student. Defaults to None.
33+
first_name (str, optional): The first name of the student. Defaults to None.
34+
last_name (str, optional): The last name of the student. Defaults to None.
35+
email (str, optional): The email address of the student. Defaults to None.
36+
date_of_birth (str, optional): The date of birth of the student. Defaults to None.
37+
grade (str, optional): The grade of the student. Defaults to None.
38+
"""
39+
self.studentDal = StudentDAL()
40+
self.id = id
41+
self.first_name = first_name
42+
self.last_name = last_name
43+
self.email = email
44+
self.date_of_birth = date_of_birth
45+
self.grade = grade
46+
47+
def add(self):
48+
"""
49+
Adds a new student record to the database using a stored procedure.
50+
51+
This method calls the `add_using_procedure` method of the `studentDal` object,
52+
passing the student's first name, last name, email, date of birth, and grade
53+
as parameters.
54+
55+
Parameters:
56+
None
57+
58+
Returns:
59+
None
60+
"""
61+
self.studentDal.add_using_procedure(
62+
self.first_name,
63+
self.last_name,
64+
self.email,
65+
self.date_of_birth,
66+
self.grade
67+
)
68+
69+
def read(self):
70+
"""
71+
Reads the student data from the data access layer (DAL) using the student's ID.
72+
73+
Returns:
74+
dict: A dictionary containing the student's data.
75+
"""
76+
return self.studentDal.read(self.id)
77+
78+
def getStudents(self):
79+
"""
80+
Retrieves a list of all students from the data access layer.
81+
82+
Returns:
83+
list: A list of student records.
84+
"""
85+
return self.studentDal.read_all()
86+
87+
def getStudentsWithClasses(self):
88+
"""
89+
Retrieves a list of students along with their associated classes.
90+
91+
Returns:
92+
list: A list of dictionaries, where each dictionary contains student information
93+
and their associated classes.
94+
"""
95+
return self.studentDal.read_all_with_classes()
96+
97+
class Teacher:
98+
"""
99+
A class to represent a teacher.
100+
101+
Attributes:
102+
----------
103+
id : int, optional
104+
The unique identifier for the teacher (default is None).
105+
first_name : str, optional
106+
The first name of the teacher (default is None).
107+
last_name : str, optional
108+
The last name of the teacher (default is None).
109+
email : str, optional
110+
The email address of the teacher (default is None).
111+
teacherDal : TeacherDAL
112+
An instance of the TeacherDAL class for database operations.
113+
114+
Methods:
115+
-------
116+
add():
117+
Adds the teacher's information to the database.
118+
read():
119+
Reads the teacher's information from the database using the teacher's id.
120+
"""
121+
122+
def __init__(self, id=None, first_name=None, last_name=None, email=None):
123+
"""
124+
Constructs all the necessary attributes for the teacher object.
125+
126+
Parameters:
127+
----------
128+
id : int, optional
129+
The unique identifier for the teacher (default is None).
130+
first_name : str, optional
131+
The first name of the teacher (default is None).
132+
last_name : str, optional
133+
The last name of the teacher (default is None).
134+
email : str, optional
135+
The email address of the teacher (default is None).
136+
"""
137+
self.teacherDal = TeacherDAL()
138+
self.id = id
139+
self.first_name = first_name
140+
self.last_name = last_name
141+
self.email = email
142+
143+
def add(self):
144+
"""
145+
Adds the teacher's information to the database.
146+
147+
This method uses the TeacherDAL instance to add the teacher's
148+
first name, last name, and email to the database.
149+
"""
150+
self.teacherDal.add(
151+
self.first_name,
152+
self.last_name,
153+
self.email
154+
)
155+
156+
def read(self):
157+
"""
158+
Reads the teacher's information from the database using the teacher's id.
159+
160+
Returns:
161+
-------
162+
dict
163+
A dictionary containing the teacher's information retrieved from the database.
164+
"""
165+
return self.teacherDal.read(self.id)
166+
167+
class Class:
168+
"""
169+
A class to represent a school class.
170+
171+
Attributes:
172+
----------
173+
id : int, optional
174+
The unique identifier for the class (default is None).
175+
room_number : str, optional
176+
The room number where the class is held (default is None).
177+
subject : str, optional
178+
The subject taught in the class (default is None).
179+
class_grade : str, optional
180+
The grade level of the class (default is None).
181+
teacher_id : int, optional
182+
The unique identifier for the teacher of the class (default is None).
183+
student_id : int, optional
184+
The unique identifier for the student in the class (default is None).
185+
classDal : ClassesDAL
186+
An instance of the ClassesDAL class for database operations.
187+
188+
Methods:
189+
-------
190+
add():
191+
Adds the class information to the database.
192+
read():
193+
Reads the class information from the database using the class id.
194+
"""
195+
196+
def __init__(self, id=None, room_number=None, subject=None, class_grade=None, teacher_id=None, student_id=None):
197+
"""
198+
Constructs all the necessary attributes for the class object.
199+
200+
Parameters:
201+
----------
202+
id : int, optional
203+
The unique identifier for the class (default is None).
204+
room_number : str, optional
205+
The room number where the class is held (default is None).
206+
subject : str, optional
207+
The subject taught in the class (default is None).
208+
class_grade : str, optional
209+
The grade level of the class (default is None).
210+
teacher_id : int, optional
211+
The unique identifier for the teacher of the class (default is None).
212+
student_id : int, optional
213+
The unique identifier for the student in the class (default is None).
214+
"""
215+
self.classDal = ClassesDAL()
216+
self.id = id
217+
self.room_number = room_number
218+
self.subject = subject
219+
self.class_grade = class_grade
220+
self.teacher_id = teacher_id
221+
self.student_id = student_id
222+
223+
def add(self):
224+
"""
225+
Adds the class information to the database.
226+
227+
This method uses the ClassesDAL instance to add the class's
228+
room number, subject, class grade, teacher id, and student id to the database.
229+
"""
230+
self.classDal.add(
231+
self.room_number,
232+
self.subject,
233+
self.class_grade,
234+
self.teacher_id,
235+
self.student_id
236+
)
237+
238+
def read(self):
239+
"""
240+
Reads the class information from the database using the class id.
241+
242+
Returns:
243+
-------
244+
dict
245+
A dictionary containing the class information retrieved from the database.
246+
"""
247+
return self.classDal.read(self.id)

0 commit comments

Comments
 (0)