fix: add fetchall() and fetchone() helper methods to DatabaseManager
- Code was calling db.fetchall() and db.fetchone() but these methods didn't exist - Add helper methods that execute query and return results - Fixes template loading and other database operations
This commit is contained in:
parent
91971d2268
commit
00d7445c26
|
|
@ -152,6 +152,34 @@ class DatabaseManager:
|
|||
conn = self.get_connection()
|
||||
return conn.executemany(query, parameters)
|
||||
|
||||
def fetchall(self, query: str, parameters: tuple = ()) -> List[sqlite3.Row]:
|
||||
"""
|
||||
Execute query and fetch all results.
|
||||
|
||||
Args:
|
||||
query: SQL query string
|
||||
parameters: Query parameters
|
||||
|
||||
Returns:
|
||||
List of row objects
|
||||
"""
|
||||
cursor = self.execute(query, parameters)
|
||||
return cursor.fetchall()
|
||||
|
||||
def fetchone(self, query: str, parameters: tuple = ()) -> Optional[sqlite3.Row]:
|
||||
"""
|
||||
Execute query and fetch first result.
|
||||
|
||||
Args:
|
||||
query: SQL query string
|
||||
parameters: Query parameters
|
||||
|
||||
Returns:
|
||||
Single row or None
|
||||
"""
|
||||
cursor = self.execute(query, parameters)
|
||||
return cursor.fetchone()
|
||||
|
||||
def commit(self) -> None:
|
||||
"""Commit current transaction."""
|
||||
if self._connection:
|
||||
|
|
|
|||
Loading…
Reference in New Issue