tokio.connectors.lmtdb module

Interface with an LMT database. Provides wrappers for common queries using the CachingDb class.

class tokio.connectors.lmtdb.LmtDb(dbhost=None, dbuser=None, dbpassword=None, dbname=None, cache_file=None)[source]

Bases: tokio.connectors.cachingdb.CachingDb

Class to wrap the connection to an LMT MySQL database or SQLite database

__init__(dbhost=None, dbuser=None, dbpassword=None, dbname=None, cache_file=None)[source]

Initialize LmtDb with either a MySQL or SQLite backend

get_mds_data(datetime_start, datetime_end, timechunk=datetime.timedelta(0, 3600))[source]

Schema-agnostic method for retrieving MDS load data.

Wraps get_timeseries_data() but fills in the exact table name used in the LMT database schema.

Parameters:
  • datetime_start (datetime.datetime) – lower bound on time series data to retrieve, inclusive
  • datetime_End (datetime.datetime) – upper bound on time series data to retrieve, exclusive
  • timechunk (datetime.timedelta) – divide time range query into sub-ranges of this width to work around N*N scaling of JOINs
Returns:

Tuple of (results, column names) where results are tuples of tuples as returned by the MySQL query and column names are the names of each column expressed in the individual rows of results.

get_mds_ops_data(datetime_start, datetime_end, timechunk=datetime.timedelta(0, 3600))[source]

Schema-agnostic method for retrieving metadata operations data.

Wraps get_timeseries_data() but fills in the exact table name used in the LMT database schema.

Parameters:
  • datetime_start (datetime.datetime) – lower bound on time series data to retrieve, inclusive
  • datetime_End (datetime.datetime) – upper bound on time series data to retrieve, exclusive
  • timechunk (datetime.timedelta) – divide time range query into sub-ranges of this width to work around N*N scaling of JOINs
Returns:

Tuple of (results, column names) where results are tuples of tuples as returned by the MySQL query and column names are the names of each column expressed in the individual rows of results.

get_oss_data(datetime_start, datetime_end, timechunk=datetime.timedelta(0, 3600))[source]

Schema-agnostic method for retrieving OSS data.

Wraps get_timeseries_data() but fills in the exact table name used in the LMT database schema.

Parameters:
  • datetime_start (datetime.datetime) – lower bound on time series data to retrieve, inclusive
  • datetime_End (datetime.datetime) – upper bound on time series data to retrieve, exclusive
  • timechunk (datetime.timedelta) – divide time range query into sub-ranges of this width to work around N*N scaling of JOINs
Returns:

Tuple of (results, column names) where results are tuples of tuples as returned by the MySQL query and column names are the names of each column expressed in the individual rows of results.

get_ost_data(datetime_start, datetime_end, timechunk=datetime.timedelta(0, 3600))[source]

Schema-agnostic method for retrieving OST data.

Wraps get_timeseries_data() but fills in the exact table name used in the LMT database schema.

Parameters:
  • datetime_start (datetime.datetime) – lower bound on time series data to retrieve, inclusive
  • datetime_End (datetime.datetime) – upper bound on time series data to retrieve, exclusive
  • timechunk (datetime.timedelta) – divide time range query into sub-ranges of this width to work around N*N scaling of JOINs
Returns:

Tuple of (results, column names) where results are tuples of tuples as returned by the MySQL query and column names are the names of each column expressed in the individual rows of results.

get_timeseries_data(table, datetime_start, datetime_end, timechunk=datetime.timedelta(0, 3600))[source]

Break a timeseries query into smaller queries over smaller time ranges. This is an optimization to avoid the O(N*M) scaling of the JOINs in the underlying SQL query.

get_ts_ids(datetime_start, datetime_end)[source]

Given a starting and ending time, return the lowest and highest ts_id values that encompass those dates, inclusive.