snews_cs.snews_sql

Attributes

current_script_directory

parent_directory

Classes

Storage

Class for interacting with the SNEWS SQL database.

Module Contents

snews_cs.snews_sql.current_script_directory[source]
snews_cs.snews_sql.parent_directory[source]
class snews_cs.snews_sql.Storage(env=None, drop_db=True)[source]

Class for interacting with the SNEWS SQL database.

Parameters:
  • env (str, optional) – Path to env file, defaults to ‘./etc/test-config.env’

  • drop_db (bool, optional) – drops all items in the DB every time Storage is initialized, defaults to False

mgs_expiration[source]
coinc_threshold[source]
db_path[source]
db[source]
conn[source]
cursor[source]
insert_mgs(mgs, tier)[source]

Inserts a message into the all_mgs table.

Parameters:

mgs (dict) – dictionary of the SNEWS message

insert_alert(alert, tier)[source]
drop_expired()[source]

Drops all expired messages from the all_mgs table.

get_all_messages(sort_order='ASC')[source]

Returns all messages in the all_mgs table.

get_all_coinc_alerts(sort_order='ASC')[source]

Returns all messages in the all_mgs table.

get_all_sig_alerts(sort_order='ASC')[source]
get_all_time_alerts(sort_order='ASC')[source]
get_all_sig_messages(sort_order='ASC')[source]

Returns all messages in the all_mgs table.

get_all_time_messages(sort_order='ASC')[source]

Returns all messages in the all_mgs table.

get_all_coinc_messages(sort_order='ASC')[source]

Returns all messages in the all_mgs table.

retract_message(message_id, tier)[source]

Retracts a message from the all_mgs table.

Parameters:

message_id (str) – unique id for each message

update_message(message, tier)[source]

Updates a message in the all_mgs table and corresponding tier tabe.

show_tables()[source]

Returns all tables in the SQL database.

get_table_schema(table_name)[source]

Returns the schema for a given table.

insert_coinc_cache(cache)[source]

Inserts coincidence cache dataframe into the coincidence_tier_archive table.

Parameters:

cache (dataframe) – dictionary of the SNEWS message

retrieve_coinc_cache()[source]

Returns coincidence cache dataframe from the coincidence_tier_archive table and saves it as a dataframe.