Odyssey
Classes | Functions | Variables
ody_migr_transaction Namespace Reference

Classes

class  PgTransaction
 

Functions

def pg_crsr_hndlr_decrtr (original_action_handler)
 

Variables

 LOGGER = logging.getLogger(__name__)
 
string PG_ARG_DEFAULT = "arg_default"
 
string PGARG_COL_SCHMA = "column_schema"
 
string PGARG_COLL = "collection"
 
string PGARG_CLN_BFRE_INSRT = "cleanup_before_insert"
 
string PGARG_RTRNG_COLMN = "returning_col"
 
string PGARG_VRBSE = "verbose"
 
string PGARG_WHR_CONDS = "where_conditions"
 
string PGARG_RTRN_ONLY_CNT = "return_only_count"
 
string PGARG_SLCT_COLS = "select_columns"
 
string PGARG_HNDLR_SPECIFIC = "handler_specific_args"
 
dictionary PGDEF_ARGS_DICT
 

Detailed Description

Main module that handles all database operations.

- Each database operation can take relevant optional parameters.
- Safe sql query generation is performed in ody_migr_db_handler.py script.

Specific handler such as `menu_insert_cu_featuremenu` must catch and
raise psycopg2 specific database errors and raise so that execute_migration
sees them and handles appropriately. A decorator `pg_crsr_hndlr_decrtr` is
used for that purpose.

Function Documentation

◆ pg_crsr_hndlr_decrtr()

def ody_migr_transaction.pg_crsr_hndlr_decrtr (   original_action_handler)
Common psycopg2 exception handler decorator

Catches and raise psycopg2 related errors and warnings.

Args:
    original_action_handler: function to wrap

Definition at line 68 of file ody_migr_transaction.py.

68 def pg_crsr_hndlr_decrtr(original_action_handler):
69  """Common psycopg2 exception handler decorator
70 
71  Catches and raise psycopg2 related errors and warnings.
72 
73  Args:
74  original_action_handler: function to wrap
75  """
76  @wraps(original_action_handler)
77  def wrapper(*args, **kwargs):
78  try:
79  return original_action_handler(*args, **kwargs)
80  except (psycopg2.Error, psycopg2.Warning):
81  raise
82  return wrapper
83 
84 

Variable Documentation

◆ PGDEF_ARGS_DICT

dictionary ody_migr_transaction.PGDEF_ARGS_DICT
Initial value:
1 = {
2  PGARG_COL_SCHMA: None,
3  PGARG_COLL: [],
4  PGARG_CLN_BFRE_INSRT: False,
5  PGARG_RTRNG_COLMN: "",
6  PGARG_VRBSE: False,
7  PGARG_WHR_CONDS: {},
8  PGARG_RTRN_ONLY_CNT: False,
9  PGARG_SLCT_COLS: [],
10  PGARG_HNDLR_SPECIFIC: {}
11 }

Definition at line 55 of file ody_migr_transaction.py.