queryId = resp.queryId
    while True:
        rst = client.fetchResults(
            TSFetchResultsReq(sessionId, stmt, fetchSize,
                              queryId)).queryDataSet
        records = convertQueryDataSet(rst, dataTypeList)
        if len(records) == 0:
            break
        for record in records:
            print(record)

    # do not forget to close it when a query is over
    closeReq = TSCloseOperationReq(sessionId)
    closeReq.queryId = queryId
    client.closeOperation(closeReq)

    # query metadata
    metaReq = TSFetchMetadataReq(sessionId=sessionId,
                                 type=MetaQueryTypes.CATALOG_DEVICES)
    print(client.fetchMetadata(metaReq).devices)

    metaReq = TSFetchMetadataReq(sessionId=sessionId,
                                 type=MetaQueryTypes.CATALOG_TIMESERIES,
                                 columnPath='root')
    print(client.fetchMetadata(metaReq).timeseriesList)

    metaReq = TSFetchMetadataReq(sessionId=sessionId,
                                 type=MetaQueryTypes.CATALOG_CHILD_PATHS,
                                 columnPath='root')
    print(client.fetchMetadata(metaReq).childPaths)
    # query the data
    stmt = "SELECT * FROM root.group1"
    fetchSize = 2
    # this is also for resource control, make sure different queries will not use the same id at the same time
    resp = client.executeQueryStatement(
        TSExecuteStatementReq(handle, stmt, stmtId))
    # headers
    dataTypeList = resp.dataTypeList
    print(resp.columns)
    print(dataTypeList)

    stmtHandle = resp.operationHandle
    status = resp.status
    print(status.statusType)

    queryId = resp.operationHandle.operationId.queryId
    while True:
        rst = client.fetchResults(TSFetchResultsReq(stmt, fetchSize,
                                                    queryId)).queryDataSet
        records = convertQueryDataSet(rst, dataTypeList)
        if len(records) == 0:
            break
        for record in records:
            print(record)

    # do not forget to close it when a query is over
    client.closeOperation(TSCloseOperationReq(stmtHandle, queryId, stmtId))

    # and do not forget to close the session before exiting
    client.closeSession(TSCloseSessionReq(handle))