narrow_down.sqlite module#
Storage backend based on SQLite.
- class narrow_down.sqlite.SQLiteStore(db_filename, partitions=128)[source]#
Bases:
StorageBackend
File-based storage backend for a SimilarityStore based on SQLite.
- __init__(db_filename, partitions=128)[source]#
Create a new empty or connect to an existing SQLite database.
- async initialize()[source]#
Initialize the tables in the SQLite database file.
- Returns:
self
- Return type:
- async query_setting(key)[source]#
Query a setting with the given key.
- Parameters:
key (str) – The identifier of the setting
- Returns:
A string with the value. If the key does not exist or the storage is uninitialized None is returned.
- Raises:
sqlite3.OperationalError – In case the database query fails for any reason.
- Return type:
str | None
- async insert_document(document, document_id=None)[source]#
Add the data of a document to the storage and return its ID.
- async remove_document(document_id)[source]#
Remove a document given by ID from the list of documents.
- Parameters:
document_id (int) –
- async add_document_to_bucket(bucket_id, document_hash, document_id)[source]#
Link a document to a bucket.