test pdoc as docgen
This commit is contained in:
327
documentation/database.md
Normal file
327
documentation/database.md
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
Module database
|
||||||
|
===============
|
||||||
|
|
||||||
|
Classes
|
||||||
|
-------
|
||||||
|
|
||||||
|
`Database(db_path: str = None)`
|
||||||
|
: Initialize the database and create the tables if they do not exist.
|
||||||
|
|
||||||
|
Default constructor for the database class
|
||||||
|
|
||||||
|
Args:
|
||||||
|
db_path (str, optional): Optional Path for testing / specific purposes. Defaults to None.
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
`addBookToDatabase(self, bookdata: src.logic.dataclass.BookData, app_id: str, prof_id: str)`
|
||||||
|
: Add books to the database. Both app_id and prof_id are required to add the book to the database, as the app_id and prof_id are used to select the books later on.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
bookdata (BookData): The metadata of the book to be added
|
||||||
|
app_id (str): The apparat id where the book should be added to
|
||||||
|
prof_id (str): The id of the professor where the book should be added to.
|
||||||
|
|
||||||
|
`addMessage(self, message: dict, user, appnr)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`changePassword(self, user, new_password)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`checkApparatExists(self, apparat_name)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`checkApparatExistsById(self, apparat_id)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`checkUsername(self, user)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`close_connection(self, conn: sqlite3.Connection)`
|
||||||
|
: closes the connection to the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
----
|
||||||
|
- conn (sql.Connection): the connection to be closed
|
||||||
|
|
||||||
|
`connect(self) ‑> sqlite3.Connection`
|
||||||
|
: Connect to the database
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
sql.Connection: The active connection to the database
|
||||||
|
|
||||||
|
`createApparat(self, apparat: src.logic.dataclass.ApparatData) ‑> Union[src.errors.DatabaseErrors.AppPresentError, ForwardRef(None), int]`
|
||||||
|
:
|
||||||
|
|
||||||
|
`createProf(self, prof_details: dict)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`createUser(self, user, password, role, salt)`
|
||||||
|
: Create a user based on passed data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
----
|
||||||
|
- username (str): Username to be used
|
||||||
|
- password (str): the salted password
|
||||||
|
- role (str): Role of the user
|
||||||
|
- salt (str): a random salt for the user
|
||||||
|
|
||||||
|
`create_tables(self)`
|
||||||
|
: Create the tables in the database
|
||||||
|
|
||||||
|
`deleteApparat(self, appnr, semester)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`deleteBook(self, book_id)`
|
||||||
|
: Delete a book from the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
book_id (str): ID of the book
|
||||||
|
|
||||||
|
`deleteMessage(self, message_id)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`deleteUser(self, user)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getAllAparats(self, deleted=0)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatCountBySemester(self) ‑> tuple[list[str], list[int]]`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatData(self, appnr, appname) ‑> src.logic.dataclass.ApparatData`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatId(self, apparat_name)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatName(self, app_id, prof_id)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatsByProf(self, prof_id: int) ‑> list[tuple]`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getApparatsBySemester(self, semester: str) ‑> dict`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getBlob(self, filename, app_id)`
|
||||||
|
: Get a blob from the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filename (str): The name of the file
|
||||||
|
app_id (str): ID of the apparat
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bytes: The file stored in
|
||||||
|
|
||||||
|
`getBook(self, book_id: int) ‑> src.logic.dataclass.BookData`
|
||||||
|
: Get the book based on the id in the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
book_id (int): The id of the book
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
BookData: The metadata of the book wrapped in a BookData object
|
||||||
|
|
||||||
|
`getBookBasedOnSignature(self, app_id: str, prof_id: str, signature: str) ‑> src.logic.dataclass.BookData`
|
||||||
|
: Get the book based on the signature of the book.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
app_id (str): The apparat id the book should be associated with
|
||||||
|
prof_id (str): The professor id the book should be associated with
|
||||||
|
signature (str): The signature of the book
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
BookData: The total metadata of the book wrapped in a BookData object
|
||||||
|
|
||||||
|
`getBookId(self, bookdata: src.logic.dataclass.BookData, app_id, prof_id) ‑> int`
|
||||||
|
: Get the id of a book based on the metadata of the book
|
||||||
|
|
||||||
|
Args:
|
||||||
|
bookdata (BookData): The wrapped metadata of the book
|
||||||
|
app_id (str): The apparat id the book should be associated with
|
||||||
|
prof_id (str): The professor id the book should be associated with
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: ID of the book
|
||||||
|
|
||||||
|
`getBookIdBasedOnSignature(self, app_id: str, prof_id: str, signature: str) ‑> int`
|
||||||
|
: Get a book id based on the signature of the book.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
app_id (str): The apparat id the book should be associated with
|
||||||
|
prof_id (str): The professor id the book should be associated with
|
||||||
|
signature (str): The signature of the book
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: The id of the book
|
||||||
|
|
||||||
|
`getBooks(self, app_id, prof_id, deleted=0) ‑> list[dict[int, src.logic.dataclass.BookData, int]]`
|
||||||
|
: Get the Books based on the apparat id and the professor id
|
||||||
|
|
||||||
|
Args:
|
||||||
|
app_id (str): The ID of the apparat
|
||||||
|
prof_id (str): The ID of the professor
|
||||||
|
deleted (int, optional): The state of the book. Set to 1 to include deleted ones. Defaults to 0.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[dict[int, BookData, int]]: A list of dictionaries containing the id, the metadata of the book and the availability of the book
|
||||||
|
|
||||||
|
`getFacultyMember(self, name: str)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getFacultyMembers(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getFiles(self, app_id: int, prof_id: int) ‑> list[tuple]`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getLastBookId(self) ‑> int`
|
||||||
|
: Get the last book id in the database
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: ID of the last book in the database
|
||||||
|
|
||||||
|
`getMessages(self, date: str)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getProfByName(self, prof_name: str)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getProfData(self, profname: str)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getProfId(self, prof_name: str)`
|
||||||
|
: getProfId _summary_
|
||||||
|
|
||||||
|
:param prof_name: _description_
|
||||||
|
:type prof_name: str
|
||||||
|
:return: _description_
|
||||||
|
:rtype: _type_
|
||||||
|
|
||||||
|
`getProfNameById(self, prof_id: int, add_title: bool = False)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getProfs(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getRole(self, user)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getRoles(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getSemersters(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getSpecificProfData(self, prof_id: int, fields: List[str])`
|
||||||
|
: getSpecificProfData _summary_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Args:
|
||||||
|
----
|
||||||
|
- prof_id (int): _description_
|
||||||
|
- fields (List[str]): _description_
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
-------
|
||||||
|
- _type_: _description_
|
||||||
|
|
||||||
|
`getSubjects(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getTitleById(self, prof_id: int)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getUnavailableApparatNumbers(self) ‑> List[int]`
|
||||||
|
: getUnavailableApparatNumbers returns a list of all currently used ApparatNumbers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
-------
|
||||||
|
- number(List[int]): a list of all currently used apparat numbers
|
||||||
|
|
||||||
|
`getUser(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`getUsers(self)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`get_db_contents(self) ‑> Optional[List[Tuple]]`
|
||||||
|
: Get the contents of the
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Union[List[Tuple], None]: _description_
|
||||||
|
|
||||||
|
`insertFile(self, file: list[dict], app_id: int, prof_id)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`insertInto(self, query: str, params: Tuple) ‑> None`
|
||||||
|
: Insert sent data into the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
query (str): The query to be executed
|
||||||
|
params (Tuple): the parameters to be inserted into the database
|
||||||
|
|
||||||
|
`isEternal(self, id)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`login(self, user, hashed_password)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`query_db(self, query: str, args: Tuple = (), one: bool = False) ‑> Union[Tuple, List[Tuple]]`
|
||||||
|
: Query the Database for the sent query.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
query (str): The query to be executed
|
||||||
|
args (Tuple, optional): The arguments for the query. Defaults to ().
|
||||||
|
one (bool, optional): Return the first result only. Defaults to False.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Union[Typle|List[Tuple]]: Returns the result of the query
|
||||||
|
|
||||||
|
`recreateFile(self, filename, app_id, filetype)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`searchBook(self, data: dict[str, str]) ‑> list[tuple[src.logic.dataclass.BookData, int]]`
|
||||||
|
: Search a book in the database based on the sent data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (dict[str, str]): A dictionary containing the data to be searched for. The dictionary can contain the following:
|
||||||
|
- signature: The signature of the book
|
||||||
|
- title: The title of the book
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[tuple[BookData, int]]: A list of tuples containing the wrapped Metadata and the id of the book
|
||||||
|
|
||||||
|
`setAvailability(self, book_id: str, available: str)`
|
||||||
|
: Set the availability of a book in the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
book_id (str): The id of the book
|
||||||
|
available (str): The availability of the book
|
||||||
|
|
||||||
|
`setNewSemesterDate(self, appnr, newDate, dauerapp=False)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`statistic_request(self, **kwargs: Any)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`updateApparat(self, apparat_data: src.logic.dataclass.ApparatData)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`updateBookdata(self, book_id, bookdata: src.logic.dataclass.BookData)`
|
||||||
|
: Update the bookdata in the database
|
||||||
|
|
||||||
|
Args:
|
||||||
|
book_id (str): The id of the book
|
||||||
|
bookdata (BookData): The new metadata of the book
|
||||||
|
|
||||||
|
`updateFacultyMember(self, data, oldlname, oldfname)`
|
||||||
|
:
|
||||||
|
|
||||||
|
`updateUser(self, username, data: dict[str, str])`
|
||||||
|
:
|
||||||
Reference in New Issue
Block a user