gurutracker.database package

Submodules

gurutracker.database.base module

class gurutracker.database.base.Base[source]

Bases: ABC

Use this as a base for all database classes. All methods except sql_query are mandatory to implement. For a full working example, see mysql.py.

abstract add_assignment(assignment)[source]
abstract add_subject(subject)[source]
abstract add_tag(tag)[source]
abstract add_tutor(tutor)[source]
abstract assignment_tags(assignment)[source]
abstract del_assignment(assignment)[source]
abstract delete_subject(subject)[source]
abstract delete_tag(tag)[source]
abstract delete_tutor(tutor)[source]
abstract edit_assignment(assignment)[source]
abstract edit_subject(subject)[source]
abstract edit_tag(tag)[source]
abstract edit_tutor(tutor)[source]
abstract get_assignment_by_id(id)[source]
abstract get_assignment_by_uid(uid)[source]
abstract get_subject_by_uid()[source]
abstract get_tag(text)[source]
abstract get_tutor_by_uid(uid)[source]
abstract list_all_assignments()[source]
abstract list_all_subjects()[source]
abstract list_tags()[source]
abstract list_tutors()[source]
abstract search_assignment_by_name_instr(name)[source]
abstract search_assignment_by_tags(tags)[source]
abstract search_tag_by_text_instr(text)[source]
abstract search_uid_by_name_instr(name)[source]
sql_query()[source]
abstract tag_assignment(assignment, tag)[source]
abstract tagged_assignments(assignment)[source]
abstract untag_assignment(assignment, tag)[source]

gurutracker.database.mysql module

class gurutracker.database.mysql.Controller(connection)[source]

Bases: Base

add_assignment(assignment)[source]
add_subject(subject)[source]
add_tag(tag)[source]
add_tutor(tutor)[source]
assignment_tags(assignment, populate_parents=True)[source]
del_assignment(assignment)[source]
delete_subject(subject)[source]
delete_tag(tag)[source]
delete_tutor(tutor)[source]
edit_assignment(assignment)[source]
edit_subject(subject)[source]
edit_tag(tag)[source]
edit_tutor(tutor)[source]
get_assignment_by_id(id)[source]
get_assignment_by_uid(uid)[source]
get_subject_by_uid(uid)[source]
get_tag(text, populate_parents=True)[source]
get_tag_by_id(id, populate_parents=True)[source]
get_tutor_by_uid(uid)[source]
list_all_assignments()[source]
list_all_assignments_customsql(custom_sql)[source]
list_all_subjects()[source]

List all subjects.

list_tags(populate_parents=True)[source]
list_tutors()[source]
search_assignment_by_name_instr(name)[source]
search_assignment_by_tags(tags)[source]
search_tag_by_text_instr(text, populate_parents=True)[source]
search_uid_by_name_instr(name)[source]
sql_query()[source]
tag_assignment(assignment, tag)[source]
tagged_assignments(tag)[source]
untag_assignment(assignment, tag)[source]

gurutracker.database.objects module

class gurutracker.database.objects.Assignment(id=None, name=None, uidentifier=None, type=None, tutor=None)[source]

Bases: object

classmethod from_list(lst)[source]
class gurutracker.database.objects.Subject(id=None, name=None, desc=None, uidentifier=None)[source]

Bases: object

class gurutracker.database.objects.Tag(id=None, text=None, fgcolor=None, bgcolor=None, parent=None)[source]

Bases: object

class gurutracker.database.objects.Tutor(id=None, name=None, uidentifier=None, subject=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.

add_subject()[source]
add_tag(tag)[source]
add_tutor(tutor)[source]
assignment_tags(assignment)[source]
del_assignment(assignment)[source]
delete_subject()[source]
delete_tag(tag)[source]
delete_tutor(tutor)[source]
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.

edit_subject()[source]
edit_tag(tag)[source]
edit_tutor(tutor)[source]
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.

get_tag(text)[source]
get_tutor_by_uid(uid)[source]
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.

list_all_subjects()[source]
list_tags()[source]
list_tutors()[source]
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_tag_by_text_instr(text)[source]
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.

sql_query()[source]
tag_assignment(assignment, tag)[source]
tagged_assignments(tag)[source]
untag_assignment(assignment, tag)[source]

Module contents