sage.database.sqlite_backends.sqlite_catalog package

Submodules

sage.database.sqlite_backends.sqlite_catalog.connector module

class sage.database.sqlite_backends.sqlite_catalog.connector.CatalogSQliteConnector(table_name, database, fetch_size=500)

Bases: sage.database.sqlite_backends.connector.SQliteConnector

A CatalogSQliteConnector search for RDF triples in a SQlite database. Constructor arguments:

  • table_name str: Name of the SQL table containing RDF data.

  • database str: the name of the sqlite database file.

  • fetch_size int: how many RDF triples are fetched per SQL query (default to 500)

delete(subject: str, predicate: str, obj: str) → None

Delete a RDF triple from the RDF Graph.

from_config() → sage.database.sqlite_backends.connector.SQliteConnector

Build a CatalogSQliteConnector from a configuration object

insert(subject: str, predicate: str, obj: str) → None

Insert a RDF triple into the RDF Graph.

search(subject, predicate, obj, last_read=None, as_of=None)

Get an iterator over all RDF triples matching a triple pattern. Args:

  • subject string - Subject of the triple pattern

  • predicate string - Predicate of the triple pattern

  • obj string - Object of the triple pattern

  • last_read string=None optional - OFFSET ID used to resume scan

  • as_of datetime=None optional - Perform all reads against a consistent snapshot represented by a timestamp.

Returns:

A tuple (iterator, cardinality), where iterator is a Python iterator over RDF triples matching the given triples pattern, and cardinality is the estimated cardinality of the triple pattern

sage.database.sqlite_backends.sqlite_catalog.iterator module

class sage.database.sqlite_backends.sqlite_catalog.iterator.SQliteIterator(cursor, connection, start_query: str, start_params: List[str], table_name: str, pattern: Dict[str, str], fetch_size: int = 500)

Bases: sage.database.db_iterator.DBIterator

A SQliteIterator implements a DBIterator for a triple pattern evaluated using a SQlite database file

has_next() → bool

Return True if there is still results to read, and False otherwise

last_read() → str

Return the index ID of the last element read

next() → Optional[Dict[str, str]]

Return the next solution mapping or None if there are no more solutions

sage.database.sqlite_backends.sqlite_catalog.queries module

sage.database.sqlite_backends.sqlite_catalog.queries.get_catalog_insert_query()

Build a SQL query to insert a RDF term into a SQlite dataset

sage.database.sqlite_backends.sqlite_catalog.queries.get_delete_query(table_name)

Build a SQL query to delete a RDF triple form a SQlite dataset

sage.database.sqlite_backends.sqlite_catalog.queries.get_insert_many_query(table_name)

Build a SQL query to insert a RDF triple into a SQlite dataset

sage.database.sqlite_backends.sqlite_catalog.queries.get_insert_query(table_name)

Build a SQL query to insert a RDF triple into a SQlite dataset

sage.database.sqlite_backends.sqlite_catalog.queries.get_locate_query()
sage.database.sqlite_backends.sqlite_catalog.queries.get_resume_query(subj, pred, obj, last_read, table_name, symbol='>=')

Get a prepared SQL query which resumes scanning for a triple pattern and the parameters used to execute it.

sage.database.sqlite_backends.sqlite_catalog.queries.get_start_query(subj, pred, obj, table_name)

Get a prepared SQL query which starts scanning for a triple pattern and the parameters used to execute it.

Module contents