Application.database#

Attributes#

Exceptions#

GarbageMessListError

Common base class for all non-exit exceptions.

Classes#

ConnectionPool

Allows database connections to be reused

Functions#

connect(→ sqlite3.Connection)

scan_mess_list(→ list[dict[str, str]])

Verifies that the csv file is a messand returns which datatype of each column

read_mess_list(path)

Populates the database with values from a csv file.

get_file_name(id)

Returns the file name skeleton which can be formated with the roll number. This

get_all_info(id)

Returns the file name skeleton which can be formated with the roll number. This

get_hoscode_roomno_from_short_id(id)

Basically only used to rename files in the event of a fuckup

set_nick(nick, id)

get_nick(id)

get_name(id)

get_all_nicks()

resolve_id(id_last_four, bhawan, roomno)

Module Contents#

Application.database.logger#
exception Application.database.GarbageMessListError[source]#

Bases: Exception

Common base class for all non-exit exceptions.

Application.database.connect() sqlite3.Connection[source]#
class Application.database.ConnectionPool[source]#

Allows database connections to be reused

Attributes:

_q: A queue.SimpleQueue that stores the connections

_q#
__enter__() sqlite3.Connection[source]#

Gets a connections from ConnectionPool._q, creates a new connection if the queue is empty.

Returns:

sqlite3.Connection

__exit__(exc_type, exc_val, exc_tb)[source]#

Commits the changes if there was no error, rolls back if there was an error. Puts the connection back into the queue.

Args:

exc_type (): exc_val (): exc_tb ():

classmethod close()[source]#

Closes all open database connections

Application.database.scan_mess_list(path: pathlib.Path) list[dict[str, str]][source]#

Verifies that the csv file is a messand returns which datatype of each column

Application.database.read_mess_list(path: pathlib.Path)[source]#

Populates the database with values from a csv file.

Args:

path: Path to the csv file

Application.database.get_file_name(id)[source]#

Returns the file name skeleton which can be formated with the roll number. This if the name of the output of the billing process.

Args:

id (): The complete ID of the person who’s image is being saved.

Returns:

str of the form “hoscode_roomno_{}_YEARLAST4DIGITS”

Application.database.get_all_info(id)[source]#

Returns the file name skeleton which can be formated with the roll number. This if the name of the output of the billing process.

Args:

id (): The complete ID of the person who’s image is being saved.

Returns:

str of the form “hoscode_roomno_{}_YEARLAST4DIGITS”

Application.database.get_hoscode_roomno_from_short_id(id)[source]#

Basically only used to rename files in the event of a fuckup

Application.database.set_nick(nick, id)[source]#
Application.database.get_nick(id)[source]#
Application.database.get_name(id)[source]#
Application.database.get_all_nicks()[source]#
Application.database.resolve_id(id_last_four, bhawan, roomno)[source]#