|
Odyssey
|
Public Member Functions | |
| def | __init__ (self, conn, cur) |
| def | __call__ (self, db_operation, arg0, *args, **kwargs) |
| def | table_exists (self, _data_category, cu_tbl_prefix, **kwargs) |
| def | display_summary (self, data_ctgry, _cu, **kwargs) |
| def | create (self, _tbl_name, **kwargs) |
| def | insert_one_record_dict (self, _tbl_name, _dict, **kwargs) |
| def | insert_one_record (self, _tbl_name, _columns, _values, **kwargs) |
| def | insert (self, _tbl_name, **kwargs) |
| def | select_count (self, _tbl_name, **kwargs) |
| def | select_and_return (self, _tbl_name, **kwargs) |
| def | select_and_print (self, _tbl_name, **kwargs) |
| def | delete (self, _tbl_name, **kwargs) |
| def | commit (self) |
| def | rollback (self) |
Public Attributes | |
| conn | |
| cur | |
Private Member Functions | |
| def | _single_table_exists (self, _tbl_name) |
Main Transaction class to enwrap multiple db operations into a single transaction. Currently, a transaction is on single connection and uses a single cursor. This class is the central object to handle all database/sql operations with the help of ody_migr_db_handler.py module being used for safe sql generation.
Definition at line 85 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.__init__ | ( | self, | |
| conn, | |||
| cur | |||
| ) |
PgTransaction constructor
Args:
conn: psycopg2 connection object
cur: psycopg2 cursor object, must be a cursor of conn
Definition at line 95 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.__call__ | ( | self, | |
| db_operation, | |||
| arg0, | |||
| * | args, | ||
| ** | kwargs | ||
| ) |
Central transaction executing calling function of PgTransaction
Performs appropriate method call based on the db_operation
Args:
db_operation: well defined database operation keyword
(CREATE, DELETE, etc)
arg0: table name for all db operation except TABLE_EXISTS,
data_category for TABLE_EXISTS and SUMMARY
in which case it is data_category
args: list of positional arguments to be forwarded to
a specified database operation handling method.
kwargs: list of keyword arguments to be forwarded to
a specified database operation handling method, mainly
used to generate sql scripts
Definition at line 105 of file ody_migr_transaction.py.
|
private |
Check if a single table exists in the database
Args:
_tbl_name: name of the table to check the existence of
Definition at line 243 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.commit | ( | self | ) |
commit this transaction
Definition at line 526 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.create | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles table creation operation
Args:
_tbl_name: name of table to create
kwargs: optional keyword arguments
Definition at line 316 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.delete | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles table record deletion operation
Args:
_tbl_name: involved table
kwargs: optional keyword arguments
Definition at line 508 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.display_summary | ( | self, | |
| data_ctgry, | |||
| _cu, | |||
| ** | kwargs | ||
| ) |
Log tables' records count summary for each data category
Args:
data_ctgry: one of {memdata, memhist, admin, settings}
_cu: current credit union code
kwargs: optional keyword arguments
Definition at line 284 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.insert | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles multiple record insertion operation
Args:
_tbl_name: name of table for insertion
kwargs: optional keyword arguments
Definition at line 384 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.insert_one_record | ( | self, | |
| _tbl_name, | |||
| _columns, | |||
| _values, | |||
| ** | kwargs | ||
| ) |
Handles single record insertion operation.
Note: columns and values are two lists in same order and script
uses general placeholder.
Args:
_tbl_name: name of table to insert a record into
_columns_: column names
_values: values to insert in the same order as column names
**kwargs: optional keyword arguments
Definition at line 359 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.insert_one_record_dict | ( | self, | |
| _tbl_name, | |||
| _dict, | |||
| ** | kwargs | ||
| ) |
Handles single record insertion operation.
Note: a record is a dictioanry and script uses named placeholder.
Args:
_tbl_name: name of table to insert a record into
_dict: record to insert
**kwargs: optional keyword arguments
Definition at line 338 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.rollback | ( | self | ) |
rollback this transaction
Definition at line 530 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.select_and_print | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles records selection from db table and print
Args:
_tbl_name: involved table
kwargs: optional keyword arguments
Definition at line 475 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.select_and_return | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles record selection and returns records or count
Args:
_tbl_name: involved table
kwargs: optional keyword arguments
Returns:
list of records or count of records
Definition at line 438 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.select_count | ( | self, | |
| _tbl_name, | |||
| ** | kwargs | ||
| ) |
Handles select and return count operation
Args:
_tbl_name: name of table
Returns:
number of records in _tbl_name for the provided condition
Definition at line 415 of file ody_migr_transaction.py.
| def ody_migr_transaction.PgTransaction.table_exists | ( | self, | |
| _data_category, | |||
| cu_tbl_prefix, | |||
| ** | kwargs | ||
| ) |
Check if required tables for each data category exist in the db
Args:
_data_category: one of {memdata, memhist, admin, settings}
cu_tbl_prefix: current credit union code
kwargs: optional keyword arguments
Returns:
all_tbls_exist: flag to notify if all required tables exist
do_not_exist_list: list of tables that donot exist if
all_tbls_exist is False
Definition at line 254 of file ody_migr_transaction.py.
1.8.15