flow.record.adapter.sqlite

Module Contents

Classes

SqliteReader

SQLite reader.

SqliteWriter

SQLite writer.

Functions

create_descriptor_table

Create table for a RecordDescriptor if it doesn't exists yet.

update_descriptor_columns

Update columns for descriptor table if new fields are added.

prepare_insert_sql

Return (cached) prepared SQL statement for inserting a record based on table name and field names.

db_insert_record

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
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
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.