def set_profile(self, guid, is_active, sort_order): """Update or Insert a profile""" # Update or insert approach, if there is no updated row then insert new one (no id changes) data = db_utils.sql_filtered_update('profiles', ['IsActive', 'SortOrder'], ['Guid'], [is_active, sort_order, guid]) cur = self._execute_query(data[0], data[1]) if cur.rowcount == 0: data = db_utils.sql_filtered_insert( 'profiles', ['Guid', 'IsActive', 'SortOrder'], [guid, is_active, sort_order]) self._execute_non_query(data[0], data[1])
def set_profile(self, guid, sort_order): """Update or Insert a profile""" # Update or insert approach, # if there is no updated row then insert new one (no id changes) if self.is_mysql_database: query = db_utils.mysql_insert_or_update( 'profiles', ['Guid'], ['SortOrder']) self._execute_non_query(query, (guid, sort_order), multi=True) else: data = db_utils.sql_filtered_update('profiles', ['SortOrder'], ['Guid'], [sort_order, guid]) cur = self._execute_query(data[0], data[1]) if cur.rowcount == 0: data = db_utils.sql_filtered_insert( 'profiles', ['Guid', 'SortOrder'], [guid, sort_order]) self._execute_non_query(data[0], data[1])