Edit of links and database versioning

This commit is contained in:
Olaf
2026-08-24 19:39:21 +02:00
parent ff249ec911
commit 28a01175f7
12 changed files with 239 additions and 8 deletions
+18
View File
@@ -57,6 +57,24 @@ def list_public_links(username: str | None = None):
return [dict(row) for row in rows]
def update_link(link_id: str, user_id: str, title: str, url: str, comment: str):
cleaned_url = clean_url(url)
with get_connection() as conn:
cursor = conn.execute(
'''
UPDATE links
SET title = ?, url = ?, comment = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ? AND user_id = ?
''',
(title, cleaned_url, comment, link_id, user_id),
)
if cursor.rowcount == 0:
return None
conn.commit()
row = conn.execute('SELECT * FROM links WHERE id = ?', (link_id,)).fetchone()
return dict(row)
def list_public_users():
with get_connection() as conn:
rows = conn.execute(