DbObject

class q2_sdk.hq.db.db_object.DbObject(logger, hq_credentials=None, ret_table_obj=None)[source]

Bases: object

Programmatic access to the Q2 database. Not as flexible as a true ORM, but takes the guesswork out of database schemas and ensures safety in the transactions.

Parameters:
  • logger – Reference to calling request’s logger (self.logger in your extension)

  • hq_credentials (Optional[HqCredentials]) – HQ Connectivity Information (Defaults to settings file)

  • ret_table_obj (Optional[bool]) – Flag to return list of LXML elements if False or TableRow objects from DB calls if True (Defaults to settings file)

GET_BY_NAME_KEY = ''
NAME = ''
REPRESENTATION_ROW_CLASS: Optional[Type[RepresentationRowBase]] = None
add_arguments(parser)[source]

Hook for subclassed DbObjects to add custom arguments.

property hq_credentials: HqCredentials
async call_hq(stored_proc_short_name, sql_parameters=None, specific_table='Table', representation_class_override=None, use_json=True, **kwargs)[source]
static serialize_for_cli(rows, fields_to_display=None, fields_to_truncate=None)[source]

Tab delimits response for printing to a terminal

Parameters:
  • rows (list) – XML elements from HQ response

  • fields_to_display (Optional[list[str]]) – Optional. Displays all fields otherwise

  • fields_to_truncate (Optional[list[str]]) – Optional. Limits display of these fields to 15 characters

Returns:

Tab delimited database rows

async get_by_name(name, get_by_name_key=None, get_func=None, **kwargs)[source]