nexusLIMS.db package

nexusLIMS.db.make_db_query(query)[source]

Execute an arbitrary query on the NexusLIMS database and return the results as a list

Parameters:

query (str) -- The SQL query to execute

Returns:

res_list -- The results of the SQL query

Return type:

list of tuple

Submodules

nexusLIMS.db.session_handler module

class nexusLIMS.db.session_handler.Session(session_identifier, instrument, dt_from, dt_to, user)[source]

Bases: object

A record of an individual session as read from the Nexus Microscopy facility session database. Created by combining two SessionLog objects with status "TO_BE_BUILT".

Parameters:
  • session_identifier (str) -- The UUIDv4 identifier for an individual session on an instrument

  • instrument (Instrument) -- An object representing the instrument associated with this session

  • dt_from (datetime) -- A datetime object representing the start of this session

  • dt_to (datetime) -- A datetime object representing the end of this session

  • user (str) -- The username associated with this session (may not be trustworthy)

insert_record_generation_event()[source]

Insert a log for this sesssion into the session database with event_type "RECORD_GENERATION"

Returns:

success -- Whether or not the update operation was successful

Return type:

bool

update_session_status(status)[source]

Update the record_status in the session logs for this Session

Parameters:

status (str) -- One of "COMPLETED", "WAITING_FOR_END", "TO_BE_BUILT", "ERROR", "NO_FILES_FOUND" (the allowed values in the NexusLIMS database). Status value will be validated by the database

Returns:

success -- Whether or not the update operation was successful

Return type:

bool

class nexusLIMS.db.session_handler.SessionLog(session_identifier, instrument, timestamp, event_type, user)[source]

Bases: object

A simple mapping of one row in the session_log table of the NexusLIMS database (all values are strings)

Parameters:
  • session_identifier (str) -- A UUID4 (36-character string) that is consistent among a single record's "START", "END", and "RECORD_GENERATION" events

  • instrument (str) -- The instrument associated with this session (foreign key reference to the instruments table)

  • timestamp (str) -- The ISO format timestamp representing the date and time of the logged event

  • event_type (str) -- The type of log for this session (either "START", "END", or "RECORD_GENERATION")

  • user (str) -- The NIST "short style" username associated with this session (if known)

nexusLIMS.db.session_handler.get_sessions_to_build()[source]

Query the NexusLIMS database for pairs of logs with status 'TO_BE_BUILT' and return the information needed to build a record for that session

Returns:

sessions -- A list of Session objects containing the sessions that the need their record built. Will be an empty list if there's nothing to do.

Return type:

list of Session