zut.db.DbDumper

class zut.db.DbDumper(dst: DbAdapter, *, table: str | tuple | None = None, add_autoincrement_pk: bool | str = False, keep_connection: bool | None = None, batch: int | None = None, **kwargs)

Bases: TabularDumper[DbAdapter]

Line-per-line INSERT commands (to be used when InsertSqlDumper is not available).

__init__(dst: DbAdapter, *, table: str | tuple | None = None, add_autoincrement_pk: bool | str = False, keep_connection: bool | None = None, batch: int | None = None, **kwargs)

Methods

__init__(dst, *[, table, ...])

append(row)

close(*final_queries)

Export remaining rows, execute optional final SQL queries, and then close the dumper.

export(row)

Called for each exported row.

export_headers(headers)

Called at first exported row, if there are no pre-existing headers.

flush(*final_queries)

Export remaining rows, and then execute optional final SQL queries.

is_available()

new_headers(headers)

Called at first exported row, if there are headers that did not exist in pre-existing headers, and for dict rows having additional keys (if additional_headers is True).

open()

Called at first exported row, before headers are analyzed.

Attributes

after1970

connection

cursor

foreign_id_keys

foreign_name_keys

truncate

dst

count

Number of appended rows.

exported_count

Number of exported rows.

close(*final_queries)

Export remaining rows, execute optional final SQL queries, and then close the dumper.

count

Number of appended rows.

export(row: list)

Called for each exported row. Row has been prepared and is a list, with values already converted if necessary. Rows are already reordered to match order of existing rows (if any), i.e. they match self._combined_headers (if defined).

export_headers(headers: list[Header])

Called at first exported row, if there are no pre-existing headers.

exported_count

Number of exported rows.

flush(*final_queries)

Export remaining rows, and then execute optional final SQL queries.

new_headers(headers: list[Header]) bool | None

Called at first exported row, if there are headers that did not exist in pre-existing headers, and for dict rows having additional keys (if additional_headers is True).

Return None to prevent adding any new header, False to allow new columns but without a header name, and True to allow updating header names.

open() list[Header] | None

Called at first exported row, before headers are analyzed.

Return list of existing headers, or None if file/headers must be created.