Nordic2Sql

This module contains all information for pushing a NordicEvent object into the database.

Functions and Classes

event2Database(nordic_event, solution_type='O', nordic_filename=None, f_creation_id=None, e_id=-1, tag_ids=None, privacy_level='public', db_conn=None)

Function that pushes a NordicEvent object to the database

Parameters:
  • nordic_event (NordicEvent) – Event that will be pushed to the database
  • solution_type (int) – event type id
  • nordic_filename (str) – name of the file from which the nordic is read from
  • f_creation_id (int) – id of the creation_info entry in the database
  • e_id (int) – id of the event to which this event will be attached to by event_root. If -1 then this event will not be attached to anything.
  • privacy_level (string) – privacy level of the event in the database
executeCommand(cur, command, vals, returnValue)

Function for for executing a command with values and handling exceptions

Parameters:
  • cur (Psycopg.Cursor) – cursor object from psycopg2 library
  • command (str) – the sql command string
  • vals (list) – list of values for the command
  • returnValue (bool) – boolean values for if the command returns a value
Returns:

Values returned by the query or None if returnValue is False

nordic_event_object_to_database(nordic_event_object, solution_type='O', nordic_filename=None, pid='', parent_pid='', root_pid='', fetch_from_pid_tree=False, creation_id=None, tag_ids=[], privacy_level='public', db_conn=None)

Function that pushes a NordicEvent object to the database. Note: this function is intended to replace the old function ‘.event2Database’.

Parameters:
  • nordic_event_object (NordicEvent) – Nordic event object that will be pushed to the database (required)
  • solution_type (str) – Solution type (as type_id of the table solution_type)
  • nordic_filename (str) – Name of the file from which the nordic file object is read from (recommended)
  • pid (str) – Persistent ID (string or Pid object, if not given a new persistent ID is generated)
  • parent_pid (str) – Persistent ID to be marked as the parent (string or Pid object, optional)
  • root_pid (str) – Root persistent ID (string or Pid object, optional)
  • fetch_from_pid_tree (boolean) – Defines whether PID is determined from a root PID defined previously.
  • creation_id (int) – ID of the creation_info entry in database (optional, if not given a new one is generated)
  • tag_ids – List of tag IDs (optional)
  • privacy_level (string) – privacy level of the event in the database (optional, default is ‘public’)
  • db_conn – An existing database connection (optional)