Download execution result¶
Download a CSV file of SQL query results that were successfully executed by the current identity.
POST https://moi.matrixorigin.cn/newmoi/query/result/download
Preparation before calling¶
First query the execution status, confirm that the status is success and obtain the result ID (statement_id). The response body is a CSV file, not JSON.
Request body¶
statement_idstringRequired- The result ID of a successful query execution.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/query/result/download" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{\"statement_id\":\"$STATEMENT_ID\"}" \
--output result.csv
Successful response¶
On success, a CSV file is returned, which the example command saves as result.csv. For example, after querying the order number, customer name and amount, the download content is as follows:
order_id,customer_name,amount
1001,王小明,128.50
1002,李华,89.00
1003,Chen Wei,256.00
The response header contains the actual file name and file size:
Successful response example
{}
Error response¶
codestring- Error code.
msgstring- Readable error message.
datanull- `null` in an error response.
Error response example
{
"code": 404,
"message": "SQL 查询结果不存在"
}
Follow-up operations¶
Use query execution result when you need to read by page.
Last updated on