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: Type[TableRow] | None = None
hq_response: HqResponse | 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, force_q2_api=False, **kwargs)[source]
Parameters:
  • stored_proc_short_name (str) – Registered in the Q2_ApiStoredProc table

  • sql_parameters (Union[SqlParameters, SqlParameters, None]) – Params to the stored proc

  • specific_table (str) – If shape returned is different than standard (rare)

  • representation_class_override – Used in cases where a DbObject has more than one return class defined

  • use_json – If False, will use the pure soap interface

  • force_q2_api – If True, will not use wedge_online_banking, even if there is an active session

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]