obspy.clients.filesystem.tsindex.TSIndexDatabaseHandler

class TSIndexDatabaseHandler(database=None, tsindex_table='tsindex', tsindex_summary_table='tsindex_summary', session=None, loglevel=None)[source]

Bases: object

Supports direct tsindex database data access and manipulation.

Warning

Direct use of this class is experimental. It cannot yet

be used to support TSIndex operation on other databases.

Public Methods

build_tsindex_summary

Builds a tsindex_summary table using the table name supplied to the Indexer instance (defaults to 'tsindex_summary').

get_tsindex_summary_cte

rtype

sqlalchemy.sql.expression.CTE

has_tsindex

Returns True if there is a tsindex table in the database.

has_tsindex_summary

Returns True if there is a tsindex_summary table in the database.

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

TSIndexDatabaseHandler._clean_query_rows(query_rows)[source]

Reformats query rows to match what is stored in the database.

Parameters

query_rows (list(tuple(str, str, str, str, UTCDateTime, UTCDateTime))) – List of tuples containing (network, station, location, channel, starttime, endtime).

TSIndexDatabaseHandler._create_query_row(network, station, location, channel, starttime, endtime)[source]

Returns a tuple (network, station, location, channel, starttime, endtime) with elements that have been formatted to match database entries. This allows for accurate comparisons when querying the database.

Parameters
  • network (str) – Network code of requested data (e.g. “IU”). Wildcards ‘*’ and ‘?’ are supported.

  • station (str) – Station code of requested data (e.g. “ANMO”). Wildcards ‘*’ and ‘?’ are supported.

  • location (str) – Location code of requested data (e.g. “”). Wildcards ‘*’ and ‘?’ are supported.

  • channel (str) – Channel code of requested data (e.g. “HHZ”). Wildcards ‘*’ and ‘?’ are supported.

  • starttime (UTCDateTime) – Start of requested time window.

TSIndexDatabaseHandler._fetch_index_rows(query_rows=None, bulk_params=None)[source]

Fetch index rows matching specified request. This method is marked as private because the index schema is subject to change.

Parameters
  • query_rows (list(tuple(str, str, str, str, UTCDateTime, UTCDateTime))) – List of tuples containing (net,sta,loc,chan,start, end). By default everything is selected.

  • bulk_params (dict) – Dict of bulk parameters (e.g. quality) Request elements may contain ‘?’ and ‘*’ wildcards. The start and end elements can be a single ‘*’ if not a date-time string.

Return type

list(tuple)

Returns

Return rows as list of named tuples containing: (network, station, location, channel, quality, starttime, endtime, samplerate, filename, byteoffset, bytes, hash, timeindex, timespans, timerates, format, filemodtime, updated, scanned, requeststart, requestend).

TSIndexDatabaseHandler._fetch_summary_rows(query_rows)[source]

Fetch summary rows matching specified request. A temporary tsindex summary is created if one does not exists. This method is marked as private because the index schema is subject to change.

Returns rows as list of named tuples containing: (network,station,location,channel,earliest,latest,updated)

Parameters

query_rows (list(tuple(str, str, str, str, UTCDateTime, UTCDateTime))) – List of tuples containing (net,sta,loc,chan,start,end) Request elements may contain ‘?’ and ‘*’ wildcards. The start and end elements can be a single ‘*’ if not a date-time string.

Return type

list(tuple)

Returns

Return rows as list of named tuples containing: (network, station, location, channel, earliest, latest, updated).

TSIndexDatabaseHandler._format_date(dt)[source]
TSIndexDatabaseHandler._set_sqlite_pragma()[source]

Setup a SQLite database for indexing.

Special Methods

TSIndexDatabaseHandler.__delattr__(name, /)

Implement delattr(self, name).

TSIndexDatabaseHandler.__dir__()

Default dir() implementation.

TSIndexDatabaseHandler.__eq__(value, /)

Return self==value.

TSIndexDatabaseHandler.__format__(format_spec, /)

Default object formatter.

TSIndexDatabaseHandler.__ge__(value, /)

Return self>=value.

TSIndexDatabaseHandler.__getattribute__(name, /)

Return getattr(self, name).

TSIndexDatabaseHandler.__gt__(value, /)

Return self>value.

TSIndexDatabaseHandler.__hash__()

Return hash(self).

TSIndexDatabaseHandler.__init__(database=None, tsindex_table='tsindex', tsindex_summary_table='tsindex_summary', session=None, loglevel=None)[source]

Main query interface to timeseries index database.

Parameters
  • database (str) – Path to sqlite tsindex database

  • tsindex_table (str) – Name of timeseries index table

  • tsindex_summary_table (str) – Name of timeseries index summary table

  • session (sqlalchemy.orm.session.Session) – An existing database session object.

TSIndexDatabaseHandler.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

TSIndexDatabaseHandler.__le__(value, /)

Return self<=value.

TSIndexDatabaseHandler.__lt__(value, /)

Return self<value.

TSIndexDatabaseHandler.__ne__(value, /)

Return self!=value.

TSIndexDatabaseHandler.__new__(**kwargs)
TSIndexDatabaseHandler.__reduce__()

Helper for pickle.

TSIndexDatabaseHandler.__reduce_ex__(protocol, /)

Helper for pickle.

TSIndexDatabaseHandler.__repr__()

Return repr(self).

TSIndexDatabaseHandler.__setattr__(name, value, /)

Implement setattr(self, name, value).

TSIndexDatabaseHandler.__sizeof__()

Size of object in memory, in bytes.

TSIndexDatabaseHandler.__str__()

Return str(self).

TSIndexDatabaseHandler.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).