enabled syntax highlighting for queries

This commit is contained in:
Lucas Jensen
2024-05-25 18:32:38 -07:00
parent b35e8406a6
commit 32f9a02528
14 changed files with 198 additions and 169 deletions

View File

@@ -8,29 +8,29 @@ class GroupQueries(BaseQueries):
self.table = GROUP_TABLE
def select_one_by_id(self) -> dict:
query = f"SELECT * FROM {self.table}"
db = self.connect_db()
cursor = db.cursor(dictionary=True)
query = f"""-- sql
SELECT * FROM {self.table}
"""
cursor, conn = self.get_cursor_and_conn()
cursor.execute(query)
data = cursor.fetchone()
cursor.close()
db.close()
data: dict = cursor.fetchone() # type: ignore
self.close_cursor_and_conn(cursor, conn)
if not data:
raise Exception("error retrieving group")
return data
def select_all_series(self) -> None:
def select_all(self) -> None:
raise NotImplementedError(
"get_all method not implemented for GroupQueries. There's only one row in the table."
)
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, conn = self.get_cursor_and_conn()
query = f"""-- sql
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()
conn.commit()
self.close_cursor_and_conn(cursor, conn)