Base DB API Class

class cdb.common.db.api.cdbDbApi.CdbDbApi

Base DB API class.

classmethod executeConnectionQuery(query)

Allows execution of simple SQL based query on the CDB db.

Parameters:query – (String) SQL query.
Returns:query results list.
classmethod executeQuery(func)

Decorator for read-only DB queries

Should never be used if data is being changed. This decorator allows queries to be performed on db.

When exceptions occur, logs and re-raises CdbExceptions.

Parameters:func – function that performs a query on the database.
Raises:CdbException – specific cdb exception
Returns:function with kwargs or session used for the communication with db.
classmethod executeTransaction(func)

Decorator for all DB transactions

Should always be used whenever data is being changed. This decorator ensures that upon exception, everything is reverted to its previous state.

When exceptions occur, logs and re-raises CdbExceptions.

Parameters:func – function that performs a query on the database.
Raises:CdbException – specific cdb exception
Returns:function with kwargs or session used for the communication with db.
classmethod getLogger()

Get an instance of a logger for the class.

Returns:logger instance.
toCdbObjectList(dbEntityList)

Converts a sqlAlchemy db entity list to cdb object list.

Parameters:dbEntityList – cdbDbEntity result list from sqlalchemy
Returns:cdbObjectList: list of type cdbObject