dragonfly.implementations.daq_db_interface module

Some template vars

Members: InsertDBEndpoint RunDBInterface exception_map Functions: Classes:

A service for interfacing with the DAQ DB (the run table in particular)

Note: services using this module will require sqlalchemy (and assuming we’re still using postgresql, psycopg2 as the sqlalchemy backend)

Summary

class dragonfly.implementations.daq_db_interface.InsertDBEndpoint(table_name, required_insert_names, return_col_names=[], optional_insert_names=[], default_insert_values={}, *args, **kwargs)

Bases: dragonfly.implementations.daq_db_interface.InsertDBEndpoint

A class for making calls to _insert_with_return

Keyword Arguments:
 
  • table_name (str) – name of the table to insert to
  • required_insert_names (list) – list of names (str) of the table columns which must be included on every requested insert
  • return_col_names (list) – list of names (str) of columns whose values should be returned on completion of the insert
  • optional_insert_names (list) – list of names (str) of columns which the user may specify on an insert request, but which may be omitted
  • default_insert_values (dict) – dictionary of {column_names: values} to serve as defaults when inserting, any values provided explicitly on the insert request will override these values
  • name (str) – unique identifier across all dripline services (used to determine routing key)
  • calibration (str||dict) – string use to process raw get result (with .format(raw)) or a dict to use for the same purpose where raw must be a key
  • get_on_set (bool) – flag to toggle running ‘on_get’ after each ‘on_set’

table_name (str): name of the table to insert to required_insert_names (list): list of names (str) of the table columns which must be included on every requested insert return_col_names (list): list of names (str) of columns whose values should be returned on completion of the insert optional_insert_names (list): list of names (str) of columns which the user may specify on an insert request, but which may be omitted default_insert_values (dict): dictionary of {column_names: values} to serve as defaults when inserting, any values provided explicitly on the insert request will override these values

do_insert(*args, **kwargs)

Calls _insert_with_return to return table column names with reply values

handle_request(channel, method, properties, request)
is_locked
lock(lockout_key=None, *args, **kwargs)
lockout_key
on_cmd(*args, **kwargs)

WARNING! if you override this method, you must ensure you deal with lockout properly

on_config(attribute, value=None)

configure a property again

WARNING! if you override this method, you must ensure you deal with lockout properly

ping(*args, **kwargs)

ignore all details and respond with an empty message

set_condition(*args, **kwargs)

To actually do something inside a class, the set_condition should be implemented in the class itself.

unlock(*args, **kwargs)
class dragonfly.implementations.daq_db_interface.RunDBInterface(database_name, database_server, tables, *args, **kwargs)

Bases: dragonfly.implementations.daq_db_interface.RunDBInterface

A not-so-flexible provider for getting run_id values.

Keyword Arguments:
 
  • database_name (str) – name of the database to connect to
  • database_server (str) – network resolvable hostname of database server
  • tables (list) – list of names (str) of tables in the database
  • name (str) – unique identifier across all dripline services (used to determine routing key)
  • calibration (str||dict) – string use to process raw get result (with .format(raw)) or a dict to use for the same purpose where raw must be a key
  • get_on_set (bool) – flag to toggle running ‘on_get’ after each ‘on_set’

database_name (str): name of the database to connect to database_server (str): network resolvable hostname of database server tables (list): list of names (str) of tables in the database

add_endpoint(endpoint)
cmd(target, method_name, value=[], payload={}, lockout_key=False, timeout=None, ignore_retcode=False)
connect_to_db(database_server, database_name, table_names)

Connects to table(s) in database server

database_server (str): name of database server, e.g localhost database_name (str): name of database, e.g p8_sc_db table_names(list of str): names of tables in database to connect to

endpoint(endpoint)
endpoint_names
endpoints
get(target, timeout=None, ignore_retcode=False)
handle_request(channel, method, properties, request)
is_locked
list_endpoints()
lock(*args, **kwargs)
lockout_key
logging_status
on_cmd(*args, **kwargs)

WARNING! if you override this method, you must ensure you deal with lockout properly

on_config(attribute, value=None)

configure a property again

WARNING! if you override this method, you must ensure you deal with lockout properly

on_send(*commands)
on_set(*args, **kwargs)
ping(*args, **kwargs)

ignore all details and respond with an empty message

schedule_status
set(target, value, lockout_key=False, timeout=None, ignore_retcode=False)
set_condition(*args, **kwargs)

To actually do something inside a class, the set_condition should be implemented in the class itself.

unlock(*args, **kwargs)

End of modules condition

Data:

End of data condition