zut.db.DbResult

class zut.db.DbResult(db: DbAdapter, cursor: T_Cursor, *, rows: list[tuple] | None, columns: list[str], query_id, tz: tzinfo | None)

Bases: ColumnsProvider, Generic[T_Cursor]

__init__(db: DbAdapter, cursor: T_Cursor, *, rows: list[tuple] | None, columns: list[str], query_id, tz: tzinfo | None)

Methods

__init__(db, cursor, *, rows, columns, ...)

as_dicts()

Return results as a list of row dictionnaries.

as_tab()

get_column_index(name)

single()

to_dumper(dumper[, close])

Send results to the given tabular dumper.

Attributes

columns

headers

lastrowid

rowcount

class Iterator(results: DbResult[T_Cursor])

Bases: Generic[T_Cursor]

as_dicts()

Return results as a list of row dictionnaries.

to_dumper(dumper: TabularDumper | IOBase | str | Path, close=True, **kwargs)

Send results to the given tabular dumper.

If dumper is tab, csv, a stream or a str/path, create the appropriate Tab/CSV/Excel dumper.

Return a tuple containing the list of columns and the number of exported rows.