UserData

class q2_sdk.hq.db.user_data.UserDataRow[source]

Bases: RepresentationRowBase

DataID: IntElement = 'DataID'
ShortName: StringElement = 'ShortName'
UserID: IntElement = 'UserID'
GTDataValue: StringElement = 'GTDataValue'
FileID: IntElement = 'FileID'
CreateDate: StringElement = 'CreateDate'
DisplayName: StringElement = 'DisplayName'
class q2_sdk.hq.db.user_data.UserDataWithUserInfoRow[source]

Bases: RepresentationRowBase

DataID: IntElement = 'DataID'
ShortName: StringElement = 'ShortName'
UserID: IntElement = 'UserID'
GTDataValue: StringElement = 'GTDataValue'
FileID: IntElement = 'FileID'
CreateDate: StringElement = 'CreateDate'
DisplayName: StringElement = 'DisplayName'
FirstName: StringElement = 'FirstName'
LastName: StringElement = 'LastName'
class q2_sdk.hq.db.user_data.UserData(logger, hq_credentials=None, ret_table_obj=None)[source]

Bases: DbObject

Allows for DB storage on a per user level. Combines the Q2_UserData and Q2_UserDataElements table.

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 = 'ShortName'
NAME = 'UserData'
REPRESENTATION_ROW_CLASS

alias of UserDataRow

RESPONSE_FIELDS = ['DataID', 'ShortName', 'UserID', 'GTDataValue', 'FileID', 'CreateDate', 'DisplayName']
add_arguments(parser)[source]

Hook for subclassed DbObjects to add custom arguments.

async get(user_id, short_name, no_trunc=False, serialize_for_cli=False)[source]
Return type:

list[UserDataRow]

async get_by_create_date_range(short_name, start_date, end_date)[source]

Get a list of user data rows filtered by short name where the CreateDate is within a date range :param: short_name: The short name of the user data element :param: start_date: The start date of the date range, as a datetime object :param: end_date: The end date of the date range, as a datetime object :rtype: list[UserDataRow] :return: A list of user data rows that fit the parameters

async get_by_short_name_paginated(short_name, page_number=1, page_size=200, exclude_empty_values=False)[source]

Get all the user data rows that match the short name with pagination :param: short_name: the short name of the user data element. Can be a string or a list of strings :param: page_number: the starting point for pagination. Defaults to 1 :param: page_size: The number of transactions to get per page :param: exclude_empty_values: If true, null or empty string GTDataValues will be excluded from the response

Return type:

list[UserDataWithUserInfoRow]

async get_by_short_name_count(short_name, exclude_empty_values=False)[source]

Get all the user data rows that match the short name with pagination :param: short_name: the short name of the user data element. Can be a string or a list of strings :param: exclude_empty_values: If true, null or empty string GTDataValues will be excluded from the response

Return type:

int

async get_by_short_name(short_name, no_trunc=False, serialize_for_cli=False)[source]

This will get all rows that have this short_name available in Q2_UserData

Return type:

list[UserDataRow]

async get_by_value(short_name, value, no_trunc=False, serialize_for_cli=False)[source]
Return type:

list[UserDataRow]

async get_multi(user_id, serialize_for_cli=False, no_trunc=False)[source]

Returns all user data associated with the given user id :type user_id: int :param user_id: user identifier :rtype: list[UserDataRow] :return: user data values for the associated user

async create(user_id, short_name, value)[source]
async update(user_id, short_name, value)[source]
async delete(user_id, data_id, online_session, online_user)[source]