squirrel.database

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.

remove(path)[source]

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).

remove_glob(pattern)[source]

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).

silent_touch(path)[source]

Update modification time of file without initiating reindexing.

Useful to prolong validity period of data with expiration date.

class DatabaseStats(**kwargs)[source]

Bases: pyrocko.guts.Object

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

nfiles

int

Number of files in database.

nnuts

int

Number of index nuts in database.

codes

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

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

kinds

list of str objects, default: []

Available content types in database.

total_size

int

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

counts

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].

persistent

list of str objects, default: []

Names of persistent selections stored in database.