From 775409f83d77eb4f98fbcac9419b99721f5c7815 Mon Sep 17 00:00:00 2001 From: user Date: Sun, 7 Apr 2024 18:08:45 +0200 Subject: derive colors from database, verify icons are in sync --- src/db_handler.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/db_handler.py') diff --git a/src/db_handler.py b/src/db_handler.py index 5798c66..0fd3ec1 100644 --- a/src/db_handler.py +++ b/src/db_handler.py @@ -7,6 +7,15 @@ with open(os.path.join('configs', 'database.yml'), 'r') as file: db_con_params = yaml.safe_load(file.read()) +def get_chains() -> (list[dict]): + with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn: + with conn.cursor() as cur: + cur.execute(""" + SELECT name, color FROM chain + """) + chains = cur.fetchall() + return chains + def get_all() -> (list[dict]): with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn: with conn.cursor() as cur: -- cgit v1.2.3