query_streaming API | Python SDK | Teradata AppCenter - query_streaming API - Teradata AppCenter

Teradata® AppCenter Python SDK User Guide

Product
Teradata AppCenter
Release Number
2.0
Published
September 2020
Language
English (United States)
Last Update
2020-09-28
dita:mapPath
hqg1594325323212.ditamap
dita:ditavalPath
ft:empty
dita:id
B035-1119
Product Category
Analytical Ecosystem

Purpose

The query_streaming API queries Teradata Database, Teradata Vantage, Aster Database, and Hive systems, and returns results as an InputStream.
The query_streaming API must be invoked using a "with" block. If you try to invoke directly, an error occurs.

Python Code Example

API Call Code
Query API call invocation
with client.query_streaming(query) as iter:
     for data in iter:
         if data:
             decoded_line = data.decode('utf-8')

Result Example

In the following example, the output JSON "columns" section contains column metadata describing the name and type of every column. The "data" section contains data from the query.
{
  "queueDuration": 33,
  "queryDuration": 47646,
  "results": [
    {
      "resultSet": true,
      "columns": [
        {
          "name": "issue",
          "type": "varchar"
        },
        {
          "name": "issue_count",
          "type": "bigint"
        }
      ],
      "data": [
        {
          "issue": "APR or interest rate",
          "issue_count": 125
        },
        {
          "issue": "Account opening, closing, or management",
          "issue_count": 804
        },
        ……
      ]
    }
  ]
}