return [row[0] for row in
self.exec(f'SELECT {column} FROM {table_name}')]
- def delete_where(self, table_name: str, key: str, target: int) -> None:
+ def delete_where(self, table_name: str, key: str,
+ target: int | str) -> None:
"""Delete from table where key == target."""
self.exec(f'DELETE FROM {table_name} WHERE {key} = ?', (target,))
if update_with_lastrowid:
self.id_ = cursor.lastrowid # type: ignore[assignment]
self.cache()
+
+ def remove(self, db_conn: DatabaseConnection) -> None:
+ """Remove from DB."""
+ assert isinstance(self.id_, int | str)
+ self.uncache()
+ db_conn.delete_where(self.table_name, 'id', self.id_)