ip сервера
This commit is contained in:
26
main.py
26
main.py
@@ -211,6 +211,32 @@ def get_records():
|
|||||||
if conn:
|
if conn:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
@app.get("/records_all_status", summary="Получить все записи избранного", response_model=List[ParsedData])
|
||||||
|
def get_records():
|
||||||
|
"""
|
||||||
|
Возвращает записи из таблицы url с избранным.
|
||||||
|
"""
|
||||||
|
conn = None
|
||||||
|
try:
|
||||||
|
conn = get_connection()
|
||||||
|
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
|
||||||
|
cur.execute("""
|
||||||
|
SELECT url, parsed_at, title, original_text, article_date, status, viewed, other, category, translation_text, short_text
|
||||||
|
FROM url
|
||||||
|
WHERE status = true
|
||||||
|
ORDER BY parsed_at DESC
|
||||||
|
""")
|
||||||
|
rows = cur.fetchall()
|
||||||
|
results = [dict(row) for row in rows]
|
||||||
|
urls = [item['parsed_at'] for item in results]
|
||||||
|
|
||||||
|
print(urls)
|
||||||
|
return results
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=500, detail=f"Ошибка при получении записей из БД: {e}")
|
||||||
|
finally:
|
||||||
|
if conn:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
# get_records()
|
# get_records()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user