database elsa changes

This commit is contained in:
WorldTeacher
2024-06-26 16:33:31 +02:00
parent d03bc0c18f
commit 8590517399
2 changed files with 29 additions and 3 deletions

View File

@@ -1301,10 +1301,24 @@ class Database:
semester (str): the semester the apparat is created in
"""
self.query_db(
"INSERT INTO elsa (date, prof_id, semester) VALUES (?,?,?)",
"INSERT OR IGNORE INTO elsa (date, prof_id, semester) VALUES (?,?,?)",
(date, prof_id, semester),
)
def updateElsaApparat(self, date, prof_id, semester, elsa_id):
"""update an ELSA apparat in the database
Args:
date (str): the name of the apparat
prof_id (int): the id of the professor
semester (str): the semester the apparat is created in
elsa_id (int): the id of the ELSA apparat
"""
self.query_db(
"UPDATE elsa SET date=?, prof_id=?, semester=? WHERE id=?",
(date, prof_id, semester, elsa_id),
)
def addElsaMedia(self, data: dict, elsa_id: int):
"""add a media to the ELSA system
@@ -1313,8 +1327,16 @@ class Database:
Structured: {"chapter":str, "title":str, "signature":str, "pages":str}
"""
self.query_db(
"INSERT INTO elsa_media (chapter, title, signature, pages, elsa_id) VALUES (?,?,?,?,?)",
(data["chapter"], data["title"], data["signature"], data["pages"], elsa_id),
"INSERT INTO elsa_media (chapter, title, signature, pages,book_author,text_author, elsa_id) VALUES (?,?,?,?,?,?,?)",
(
data["chapter"],
data["title"],
data["signature"],
data["pages"],
data["book_author"],
data["text_author"],
elsa_id,
),
)
def getElsaMedia(self, elsa_id: int):

View File

@@ -99,6 +99,10 @@ CREATE_ELSA_MEDIA_TABLE = """CREATE TABLE elsa_media (
title TEXT NOT NULL,
signature TEXT NOT NULL,
pages TEXT NOT NULL,
text_author TEXT,
book_author TEXT NOT NULL,
type TEXT NOT NULL,
elsa_id INTEGER NOT NULL,
data TEXT NOT NULL,
FOREIGN KEY (elsa_id) REFERENCES elsa (id)
)"""