SQLite

class korus.database.backend.sqlite.sqlite.SQLiteBackend(path: str, new: bool = False, **kwargs)[source]

Bases: DatabaseBackend, Connection

property annotation: SQLiteTableBackend
property deployment: SQLiteTableBackend
property file: SQLiteTableBackend
property granularity: SQLiteTableBackend
property job: SQLiteTableBackend
property korus_version: str

Get Korus version used to create the database.

Returns:
version: str

The Korus version in the form x.y.z

property label: SQLiteTableBackend
property storage: SQLiteTableBackend
property tag: SQLiteTableBackend
property taxonomy: SQLiteTableBackend
class korus.database.backend.sqlite.sqlite.SQLiteJobBackend(conn: Connection, codec: Codec)[source]

Bases: SQLiteTableBackend

add_file(job_id: int, file_id: int, channel: int = 0)[source]
get_files(job_id: int | list[int]) list[tuple[int, int]][source]
class korus.database.backend.sqlite.sqlite.SQLiteTableBackend(conn: Connection, name: str, codec: Codec)[source]

Bases: TableBackend

Generic SQLite table backend.

Note: The SQLite table and its associated _field table must be created before instantiating this class.

Args:
conn: sqlite3.Connection

The database connection

name: str

The table name

codec: korus.database.backend.sqlite.encode.Codec

Encoder-decoder for inserting and retrieving data from the database

add(row: dict) int[source]
add_codec(field_name: str, field_type: Any)[source]

Add default encoding and decoding rules for the specified field.

Args:
field_name: str

The field’s name

field_type:

The field’s type

add_field(name: str, type: Any, default: Any = None, required: bool = True)[source]
filter(*conditions: dict, indices: list[int] | None = None, **kwargs) list[int][source]
get(indices: int | list[int] | None = None, fields: str | list[str] | None = None, return_indices: bool = False) list[tuple][source]
get_fields() list[dict][source]

Get custom field descriptions saved to the database

Returns:
field_attrs: list[dict]

The field attributes

remove(indices: int | list[int] | None = None)[source]
reset_cursor()[source]

Return to first row

save_field(field_attrs: dict)[source]

Save custom field description to the database

Args:
field_attrs: dict

The field attributes

set_cursor(idx: int)[source]

Move to a given row

update(idx: int, row: dict)[source]
korus.database.backend.sqlite.sqlite.rename_key(x, old_name, new_name)[source]

Helper function for renaming key in dict