gurutracker.database package¶
Submodules¶
gurutracker.database.base module¶
gurutracker.database.mysql module¶
gurutracker.database.objects module¶
- class gurutracker.database.objects.Assignment(id=None, name=None, uidentifier=None, type=None, tutor=None)[source]¶
Bases:
object
- class gurutracker.database.objects.Subject(id=None, name=None, desc=None, uidentifier=None)[source]¶
Bases:
object
gurutracker.database.sqlite3 module¶
A module that provides a controller class for interacting with SQLite3 databases.
This module defines a Controller class that inherits from Base class defined in gurutracker.database.base. The Controller class has methods for creating, updating, deleting and querying assignments and tutors from SQLite3 databases. It also has methods for validating user inputs and generating reports.
- gurutracker.database.sqlite3.DATABASE_NAME¶
The name of the database file to use.
- Type:
str
Example
To use the Controller class, first import it from this module:
from gurutracker.database.sqlite3 import Controller
Then create an instance of the Controller class with the database name:
controller = Controller(DATABASE_NAME)
You can then call any of the methods defined in the Controller class on the controller object, such as:
controller.list_all_assignments() controller.add_assignment(name=”Math Homework”, uidentifier=”MATH-001”, type=”Homework”, tid=1) controller.delete_assignment_by_id(2) controller.generate_report_by_subject(“Math”)
Note
Documentation for this module generated by Bing ChatGPT, so may not be accurate.
- class gurutracker.database.sqlite3.Controller(connection)[source]¶
Bases:
Base
- add_assignment(assignment)[source]¶
Add a new assignment to the database.
This method executes a SQL query to insert a new assignment and its related tutor information to the database. It then updates the id attribute of the Assignment object with the generated id from the database.
- Parameters:
assignment (Assignment) – The Assignment object to add to the database.
- Returns:
None.
- edit_assignment(assignment)[source]¶
Edit an existing assignment in the database.
This method executes a SQL query to update an existing assignment and its related tutor information in the database. It uses the id attribute of the
Assignment object as a condition for updating.
- Parameters:
assignment (Assignment) – The Assignment object with updated attributes
database. (to edit in the) –
- Returns:
None.
- get_assignment_by_id(id)[source]¶
Get an assignment by its id.
This method executes a SQL query to select an assignment and its related tutor information from the database by its id. It then creates an Assignment object and a Tutor object for the row and returns them.
- Parameters:
id (int) – The id of the assignment to get.
- Returns:
An Assignment object with its associated Tutor object if found, or None otherwise.
- get_assignment_by_uid(uid)[source]¶
Get an assignment by its unique identifier.
This method executes a SQL query to select an assignment and its related tutor information from the database by its unique identifier. It then creates an Assignment object and a Tutor object for the row and returns them.
- Parameters:
uid (str) – The unique identifier of the assignment to get.
- Returns:
An Assignment object with its associated Tutor object if found, or None otherwise.
- list_all_assignments()[source]¶
List all assignments with their corresponding tutors.
This function executes a SQL query to select all assignments and their related tutor information from the database. It then creates Assignment and Tutor objects for each row and appends them to a list.
- Returns:
A list of Assignment objects with their associated Tutor objects.
- list_all_assignments_customsql(custom_sql)[source]¶
List all assignments with their corresponding tutors using a custom SQL query.
This function executes a SQL query that is composed of a base query and a custom SQL string provided by the user. It then creates Assignment and Tutor objects for each row and appends them to a list.
- Parameters:
custom_sql – A string containing additional SQL clauses to filter or sort the assignments.
- Returns:
- A list of Assignment objects with their associated Tutor objects that match
the custom SQL query.
- Raises:
sqlite3.Error: If there is an error in executing the SQL query.
- search_assignment_by_name_instr(name)[source]¶
Search assignments by their name using a partial match and sort them by id.
This method executes a SQL query to select all assignments and their related tutor information from the database that have a partial match with the given name. It then creates Assignment objects and Tutor objects for each row and appends them to a list. The list is sorted by the id of the assignments in ascending order.
- Parameters:
name (str) – The name or part of the name of the assignments to search.
- Returns:
A list of Assignment objects with their associated Tutor objects that match the search criteria and are sorted by id.
- search_assignment_by_tags(tags)[source]¶
Search assignments by their tags using an exact match.
This method is not implemented yet. It should execute a SQL query to select all assignments and their related tutor information from the database that have an exact match with the given tags. It then should create Assignment objects and Tutor objects for each row and append them to a list.
- Parameters:
tags (list of str) – The tags of the assignments to search.
- Returns:
A list of Assignment objects with their associated Tutor objects that match the search criteria.
- search_uid_by_name_instr(name)[source]¶
Search assignments by their unique identifier using a partial match and sort them by id.
This method executes a SQL query to select all assignments and their related tutor information from the database that have a partial match with the given unique identifier. It then creates Assignment objects and Tutor objects for each row and appends them to a list. The list is sorted by the id of the assignments in ascending order.
- Parameters:
name (str) – The unique identifier or part of it of the assignments to search.
- Returns:
A list of Assignment objects with their associated Tutor objects that match the search criteria and are sorted by id.