To return an API response in CSV format, set the *format* field in the request with the value *CSV*.
The CSV format contains only the query results and not response metadata. The response contains a line for each row, where each line contains the row columns separated by a comma. The following example returns the data as comma-separated values.
Request
# CSV with all rows included
url = 'https://<QS_HOSTNAME>:1443/systems/<SYSTEM_NAME>/queries'
payload = {
'query': example_query, # 'SELECT * FROM DBC.DBCInfo;',
'format': 'CSV',
'includeColumns': True
}
payload_json = json.dumps(payload)
response = requests.request('POST', url, headers=headers, data=payload_json, verify=False)
print(response.text)
Response
DatabaseName,USEDSPACE_IN_GB,MAXSPACE_IN_GB,Percentage_Used,REMAININGSPACE_IN_GB
DBC ,317.7634754180908,1510.521079641879,21.036679308932754,1192.7576042237881
EM ,7.491111755371094E-4,11.546071618795395,0.006488017745513208,11.545322507619858
user10 ,0.019153594970703125,9.313225746154785,0.20566016,9.294072151184082
EMEM ,0.006140708923339844,4.656612873077393,0.13187072,4.650472164154053
EMWork ,0.0,4.656612873077393,0.0,4.656612873077393
EMJI ,0.0,2.3283064365386963,0.0,2.3283064365386963
USER_NAME ,0.0,2.0,0.0,2.0
readonly ,0.0,0.9313225746154785,0.0,0.9313225746154785
aug12_db ,7.200241088867188E-5,0.9313225746154785,0.0077312,0.9312505722045898
SystemFe ,1.8024444580078125E-4,0.7450580596923828,0.024192,0.744877815246582
dbcmngr ,3.814697265625E-6,0.09313225746154785,0.004096,0.09312844276428223
EMViews ,0.027594566345214844,0.09313225746154785,29.62944,0.06553769111633301
tdwm ,6.732940673828125E-4,0.09313225746154785,0.722944,0.09245896339416504
Crashdumps ,0.0,0.06984921544790268,0.0,0.06984921544790268
SYSLIB ,0.006252288818359375,0.03725290298461914,16.78336,0.031000614166259766
SYSBAR ,4.76837158203125E-6,0.03725290298461914,0.0128,0.03724813461303711
SYSUDTLIB ,3.5381317138671875E-4,0.029802322387695312,1.1872,0.029448509216308594
External_AP ,0.0,0.01862645149230957,0.0,0.01862645149230957
SysAdmin ,0.002307891845703125,0.01862645149230957,12.3904,0.016318559646606445
KZXaDtQp ,0.0,0.009313225746154785,0.0,0.009313225746154785
s476QJ6O ,0.0,0.009313225746154785,0.0,0.009313225746154785
hTzz03i7 ,0.0,0.009313225746154785,0.0,0.009313225746154785
Y5WYUUXj ,0.0,0.009313225746154785,0.0,0.009313225746154785