add execute_many method to Database class and update fetch_reddit endpoint to insert posts into database

This commit is contained in:
2026-01-11 14:44:22 +00:00
parent 1e9eb11aa1
commit 5e1bccb2a8
2 changed files with 12 additions and 2 deletions

View File

@@ -21,6 +21,10 @@ class Database:
if cursor.description:
return cursor.fetchall()
return []
def execute_many(self, query: str, params_list: list[tuple]):
with self.connection.cursor(cursor_factory=RealDictCursor) as cursor:
cursor.executemany(query, params_list)
def close(self):
self.connection.close()