def test_sql(client): # cleanup client.sql(drop_query) result = sql_fields( client, 'PUBLIC', create_query, page_size, include_field_names=True ) assert result.status == 0, result.message for i, data_line in enumerate(initial_data, start=1): fname, lname, grade = data_line result = sql_fields( client, 'PUBLIC', insert_query, page_size, query_args=[i, fname, lname, grade], include_field_names=True ) assert result.status == 0, result.message result = cache_get_configuration(client, 'SQL_PUBLIC_STUDENT') assert result.status == 0, result.message binary_type_name = result.value[PROP_QUERY_ENTITIES][0]['value_type_name'] result = sql( client, 'SQL_PUBLIC_STUDENT', binary_type_name, 'TRUE', page_size ) assert result.status == 0, result.message assert len(result.value['data']) == page_size assert result.value['more'] is True for wrapped_object in result.value['data'].values(): data = unwrap_binary(client, wrapped_object) assert data.type_id == entity_id(binary_type_name) cursor = result.value['cursor'] while result.value['more']: result = sql_cursor_get_page(client, cursor) assert result.status == 0, result.message for wrapped_object in result.value['data'].values(): data = unwrap_binary(client, wrapped_object) assert data.type_id == entity_id(binary_type_name) # repeat cleanup result = sql_fields(client, 'PUBLIC', drop_query, page_size) assert result.status == 0
def __next__(self): if not self.data: raise StopIteration try: k, v = next(self.data) except StopIteration: if self.more: result = sql_cursor_get_page(self.connection, self.cursor_id) if result.status != 0: raise SQLError(result.message) self.data, self.more = iter( result.value['data'].items()), result.value['more'] k, v = next(self.data) else: raise StopIteration return self.client.unwrap_binary(k), self.client.unwrap_binary(v)