diff options
| author | user@node5.net <user@node5.net> | 2025-08-23 22:38:01 +0200 |
|---|---|---|
| committer | user@node5.net <user@node5.net> | 2025-08-23 22:38:01 +0200 |
| commit | 9dc138950dabfcf12a624fe400d1085046668f25 (patch) | |
| tree | 88ef3d4f9f1af480fb7c4dd5b91faafe97ac5832 /src/db_handler.py | |
| parent | deaa5a3a314787f61394df2de8ba458bc5e356c5 (diff) | |
Revamp comments style like sql statements
Diffstat (limited to 'src/db_handler.py')
| -rw-r--r-- | src/db_handler.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/db_handler.py b/src/db_handler.py index 6789105..471154a 100644 --- a/src/db_handler.py +++ b/src/db_handler.py @@ -15,14 +15,15 @@ class DBHandler: def get_comments(self, url: str) -> list[dict]: with self.con_factory() as con: cur = con.cursor() - cur.execute( - ''' - SELECT id, nickname, comment, page_url, visitor_url, (CASE WHEN show_contact THEN contact ELSE NULL END) as contact_info, created_at - FROM comment WHERE approved AND public AND page_url = ? ORDER BY created_at DESC; - ''', (url,)) + comments_sql = ''' +SELECT id, nickname, comment, page_url, visitor_url, (CASE WHEN show_contact THEN contact ELSE NULL END) as contact_info, created_at +FROM comment WHERE approved AND public AND page_url = ? ORDER BY created_at DESC; +''' + cur.execute(comments_sql, (url,)) comments = cur.fetchall() headers = list(map(lambda attr : attr[0], cur.description)) - return comments, headers + comments_sql = comments_sql.replace('?', f"'{url}'") + return comments, headers, comments_sql def post_comment(self, comment: str, page_url: str, visitor_url: str=None, nickname: str=None, contact: str=None, |
