snews_cs.snews_sql ================== .. py:module:: snews_cs.snews_sql Attributes ---------- .. autoapisummary:: snews_cs.snews_sql.current_script_directory snews_cs.snews_sql.parent_directory Classes ------- .. autoapisummary:: snews_cs.snews_sql.Storage Module Contents --------------- .. py:data:: current_script_directory .. py:data:: parent_directory .. py:class:: Storage(env=None, drop_db=True) Class for interacting with the SNEWS SQL database. :param env: Path to env file, defaults to './etc/test-config.env' :type env: `str`, optional :param drop_db: drops all items in the DB every time Storage is initialized, defaults to False :type drop_db: `bool`, optional .. py:attribute:: mgs_expiration .. py:attribute:: coinc_threshold .. py:attribute:: db_path .. py:attribute:: db .. py:attribute:: conn .. py:attribute:: cursor .. py:method:: insert_mgs(mgs, tier) Inserts a message into the all_mgs table. :param mgs: dictionary of the SNEWS message :type mgs: `dict` .. py:method:: insert_alert(alert, tier) .. py:method:: drop_expired() Drops all expired messages from the all_mgs table. .. py:method:: get_all_messages(sort_order='ASC') Returns all messages in the all_mgs table. .. py:method:: get_all_coinc_alerts(sort_order='ASC') Returns all messages in the all_mgs table. .. py:method:: get_all_sig_alerts(sort_order='ASC') .. py:method:: get_all_time_alerts(sort_order='ASC') .. py:method:: get_all_sig_messages(sort_order='ASC') Returns all messages in the all_mgs table. .. py:method:: get_all_time_messages(sort_order='ASC') Returns all messages in the all_mgs table. .. py:method:: get_all_coinc_messages(sort_order='ASC') Returns all messages in the all_mgs table. .. py:method:: retract_message(message_id, tier) Retracts a message from the all_mgs table. :param message_id: unique id for each message :type message_id: `str` .. py:method:: update_message(message, tier) Updates a message in the all_mgs table and corresponding tier tabe. .. py:method:: show_tables() Returns all tables in the SQL database. .. py:method:: get_table_schema(table_name) Returns the schema for a given table. .. py:method:: insert_coinc_cache(cache) Inserts coincidence cache dataframe into the coincidence_tier_archive table. :param cache: dictionary of the SNEWS message :type cache: dataframe .. py:method:: retrieve_coinc_cache() Returns coincidence cache dataframe from the coincidence_tier_archive table and saves it as a dataframe.