libgs.database.KVDb

class libgs.database.KVDb(db, table, ncols=[], ntypes=Text(), **kwargs)[source]

Generic Key-Value database with optional “standard” fields (columns).

This class is not used directly. See MonitorDb and PassDb

When initialised by itself, this class will create a key/value database with two columns; key and value that can store arbitrary data. Values will be attempted encoded using JSON, which allows the database to store almost arbitrary data types.

Additionally a set of other columns can be specified with any sqlalchemytype required.

Parameters:
  • ncols – Normal columns; a list of column names
  • ntypes – SQLAlchemy types associated with the columns (defaults to Text)

See Database for the definition of the additional arguments.

Methods

get([limit, keys, tstamps]) Get data from the database.
put(key, value, **kwargs) Add key/value pair to database.

Inherited from base class

count_rows(table) Return the number of rows in a table
create_table(name, *columns, **kwargs) Set up the columns and add a unique key.
get_df(table[, where, limit, orderby, …]) Get data from communications database as a pandas.DataFrame object
get_file(fname) Grab a file resource and return the bytes or string (.bin or .txt)
put_df(table, df[, index, if_exists]) Add dataframe to database, appending metadata for when it was added