This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user