test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-05-03 13:48:49 +10:00
parent 8f86c51d19
commit 0577f4d65c
2 changed files with 7 additions and 4 deletions

View File

@@ -345,12 +345,15 @@ def add_sources(url: str, promt: str):
finally:
pass
def get_all_sources():
def get_all_sources(category: str):
"""Возвращает все записи из таблицы sourse"""
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT * FROM sourse")
if category == "all":
cur.execute("SELECT * FROM sourse")
else:
cur.execute("SELECT * FROM sourse WHERE category = %s", (category,))
rows = cur.fetchall()
sources = [{"url": row["url"], "promt": row["promt"]} for row in rows]
return {"sources": sources}