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: Path)[source]#

Bases: object

Local database interface

close()[source]#

Close the connection to the database.

create_table(cur: Cursor)[source]#

Create the table where the SWHIDs will be stored.

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

Insert the SWHID inside the database.

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

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

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

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