From 6867fb3011d7ff658472163902dd4e6737bf6e60 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 15 Mar 2022 18:17:23 -0700 Subject: [PATCH] Remove normalize_db_row, just use row_factory = Row. --- voussoirkit/worms.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/voussoirkit/worms.py b/voussoirkit/worms.py index 12181d1..591f1f0 100644 --- a/voussoirkit/worms.py +++ b/voussoirkit/worms.py @@ -115,6 +115,9 @@ class Database(metaclass=abc.ABCMeta): def _init_sql(self): ''' Your subclass needs to set self.sql, which is a database connection. + + It is recommended to set self.sql.row_factory = sqlite3.Row so that you + get dictionary-style named access to row members in your objects' init. ''' raise NotImplementedError @@ -277,20 +280,6 @@ class Database(metaclass=abc.ABCMeta): query = f'INSERT INTO {table} VALUES({qmarks})' return self.execute(query, bindings) - def normalize_db_row(self, db_row, table) -> dict: - ''' - Raises KeyError if table is not one of the recognized tables. - - Raises TypeError if db_row is not the right type. - ''' - if isinstance(db_row, dict): - return db_row - - if isinstance(db_row, (list, tuple)): - return dict(zip(self.COLUMNS[table], db_row)) - - raise TypeError(f'db_row should be {dict}, {list}, or {tuple}, not {type(db_row)}.') - def release_savepoint(self, savepoint, allow_commit=False) -> None: ''' Releasing a savepoint removes that savepoint from the timeline, so that