flow.record.adapter.sqlite
¶
Module Contents¶
Classes¶
SQLite reader. |
|
SQLite writer. |
Functions¶
Create table for a RecordDescriptor if it doesn't exists yet. |
|
Update columns for descriptor table if new fields are added. |
|
Return (cached) prepared SQL statement for inserting a record based on table name and field names. |
|
Insert a record into the database. |
Attributes¶
- flow.record.adapter.sqlite.logger¶
- flow.record.adapter.sqlite.__usage__ = Multiline-String¶
Show Value
""" SQLite adapter --- Write usage: rdump -w sqlite://[PATH]?batch_size=[BATCH_SIZE] Read usage: rdump sqlite://[PATH]?batch_size=[BATCH_SIZE] [PATH]: path to SQLite database file Optional parameters: [BATCH_SIZE]: number of records to read or write in a single transaction (default: 1000) """
- flow.record.adapter.sqlite.FIELD_MAP¶
- flow.record.adapter.sqlite.SQLITE_FIELD_MAP¶
- flow.record.adapter.sqlite.create_descriptor_table(con: sqlite3.Connection, descriptor: flow.record.RecordDescriptor) None ¶
Create table for a RecordDescriptor if it doesn’t exists yet.
- flow.record.adapter.sqlite.update_descriptor_columns(con: sqlite3.Connection, descriptor: flow.record.RecordDescriptor) None ¶
Update columns for descriptor table if new fields are added.
- flow.record.adapter.sqlite.prepare_insert_sql(table_name: str, field_names: tuple[str]) str ¶
Return (cached) prepared SQL statement for inserting a record based on table name and field names.
- flow.record.adapter.sqlite.db_insert_record(con: sqlite3.Connection, record: flow.record.Record) None ¶
Insert a record into the database.
- class flow.record.adapter.sqlite.SqliteReader(path: str, *, batch_size: str | int = 1000, selector: flow.record.selector.Selector | str | None = None, **kwargs)¶
Bases:
flow.record.adapter.AbstractReader
SQLite reader.
- logger¶
- selector¶
- descriptors_seen¶
- con¶
- count = 0¶
- batch_size¶
- table_names() list[str] ¶
Return a list of table names in the database.
- read_table(table_name: str) Iterator[flow.record.Record] ¶
Read a table from the database and yield records.
- __iter__() Iterator[flow.record.Record] ¶
Iterate over all tables in the database and yield records.
- class flow.record.adapter.sqlite.SqliteWriter(path: str, *, batch_size: str | int = 1000, **kwargs)¶
Bases:
flow.record.adapter.AbstractWriter
SQLite writer.
- logger¶
- descriptors_seen¶
- con = None¶
- count = 0¶
- batch_size¶
- write(record: flow.record.Record) None ¶
Write a record to the database
- tx_cycle() None ¶
- flush() None ¶
Flush any buffered writes.
- close() None ¶
Close the Writer, no more writes will be possible.