initial commit

This commit is contained in:
Lucas Jensen
2024-05-01 09:19:01 -07:00
commit 5d67c0c2b2
117 changed files with 9917 additions and 0 deletions

36
server/app/db/group.py Normal file
View File

@@ -0,0 +1,36 @@
from app.db.base_queries import BaseQueries
from app.models.group import GROUP_TABLE
class GroupQueries(BaseQueries):
def __init__(self) -> None:
super().__init__()
self.table = GROUP_TABLE
async def get_one(self) -> dict:
query = f"SELECT * FROM {self.table}"
db = self.connect_db()
cursor = db.cursor(dictionary=True)
cursor.execute(query)
data = cursor.fetchone()
cursor.close()
db.close()
if not data:
raise Exception("error retrieving group")
return data
async def get_all(self) -> None:
raise NotImplementedError(
"get_all method not implemented for GroupQueries. There's only one row in the table."
)
async def update_group_bio(self, bio: str) -> None:
db = self.connect_db()
cursor = db.cursor()
query = f"UPDATE {self.table} SET bio = %s WHERE id = 1" # only one row in the table
cursor.execute(query, (bio,))
db.commit()
cursor.close()
db.close()