UPDATE: Added functionality that updates database on stream start and on stream end. Adds new stream to database

This commit is contained in:
2025-01-29 00:59:05 +00:00
parent bc1a48a571
commit 6964234231
4 changed files with 41 additions and 4 deletions

View File

@@ -30,7 +30,21 @@ class Database:
result = self.cursor.fetchone()
return self.convert_to_list_dict(result)
def execute(self, query: str, parameters=None) -> None:
"""
Executes a command (e.g., INSERT, UPDATE, DELETE) and commits the changes.
"""
try:
if parameters:
self.cursor.execute(query, parameters)
else:
self.cursor.execute(query)
self.commit_data()
except Exception as e:
print(f"Error executing command: {e}")
raise
def convert_to_list_dict(self, result):
"""
Converts a query result to a list of dictionaries
@@ -47,7 +61,7 @@ class Database:
else:
# for fetchall or fetchmany
return [dict(zip(columns, row)) for row in result]
def commit_data(self):
try:
self._conn.commit()