class Database(database_path=':memory:', log_statements=False)[source]

Bases: object

Shared meta-information database used by Squirrel.

dig(nuts, transaction=None)[source]

Store or update content meta-information.

Given nuts are assumed to represent an up-to-date and complete inventory of a set of files. Any old information about these files is first pruned from the database (via database triggers). If such content is part of a live selection, it is also removed there. Then the new content meta-information is inserted into the main database. The content is not automatically inserted into the live selections again. It is in the responsibility of the selection object to perform this step.


Prune content meta-information about a given file.

All content pieces belonging to file path are removed from the main database and any attached live selections (via database triggers).


Prune content meta-information about files matching given pattern.

All content pieces belonging to files who’s pathes match the given pattern are removed from the main database and any attached live selections (via database triggers).

reset(path, transaction=None)[source]

Prune information associated with a given file, but keep the file path.

This method is called when reading a file failed. File attributes, format, size and modification time are set to NULL. File content meta-information is removed from the database and any attached live selections (via database triggers).


Update modification time of file without initiating reindexing.

Useful to prolong validity period of data with expiration date.

class DatabaseStats(**kwargs)[source]

Bases: Object

Container to hold statistics about contents cached in meta-information db.



Number of files in database.



Number of index nuts in database.


list of tuple of str objects objects, default: []

Available code sequences in database, e.g. (agency, network, station, location) for stations nuts.


list of str objects, default: []

Available content types in database.



Aggregated file size [bytes] of files referenced in database.


dict of dict of int objects objects, default: {}

Breakdown of how many nuts of any content type and code sequence are available in database, counts[kind][codes].


list of str objects, default: []

Names of persistent selections stored in database.