swh.scanner.db module

This module is an interface to interact with the local database where the SWHIDs will be saved for the local API.

SWHIDs can be added directly from an input file.

class swh.scanner.db.Db(db_file: pathlib.Path)[source]

Bases: object

Local database interface

close()[source]

Close the connection to the database.

create_table(cur: sqlite3.Cursor)[source]

Create the table where the SWHIDs will be stored.

add(swhids: Iterable[str], chunk_size: int, cur: sqlite3.Cursor)[source]

Insert the SWHID inside the database.

static iter_swhids(lines: Iterable[str]) Iterable[str][source]
create_from(input_file: _io.TextIOWrapper, chunk_size: int, cur: sqlite3.Cursor)[source]

Create a new database with the SWHIDs present inside the input file.

known(swhid: str, cur: sqlite3.Cursor)[source]

Check if a given SWHID is present or not inside the local database.