/db2whrest/v1/sql_query?<sql>: GET
Retrieves data from a database with an SQL query in a GET command. You can use any
standard SQL query. You must include the SQL query as a parameter of the URL.
To send the query in an HTTP message body, see /db2whrest/v1/sql_query: POST.
The following table shows which roles can access this REST API endpoint:
Data admin | Data user | Collection Admin | Admin | Service user |
---|---|---|---|---|
✓ | ✓1 | ✓1 | Χ | Χ |
1The search is restricted to documents that are tagged with collections to which the user has a datauser role assigned. |
Synopsis of the request URL
curl -k -H 'Authorization: Bearer <token>' https://<spectrum_discover_host>/db2whrest/v1/sql_query?<sql_statements> -X GET
Supported request types and response formats
Supported request types:
- GET
- CSV
- JSON
Examples
- The following example shows how to get data from a database with an SQL query in a GET command.
The SQL query is included as a parameter of the URL. This example specifies that the data must be
returned in JSON format:
- Submit the
request:
curl -k -H 'Authorization: Bearer <token>' https://<spectrum_discover_host>/db2whrest/v1/sql_query?select%20*%20from%20meteor%20limit%202 -X GET -H "Accept: application/json"
- The following response is
returned:
[{"datasource":"ctolib","operation":"INDEX","ingesttype":"SCAN","revision":"MO1","site": "","platform":"Spectrum Scale","cluster":"ctolib.cluster1","inode":4042,"owner":"user1", "group":"group1","permissions":"-rw-r--r--","fileset":"brother","uid":null,"gid":null, "path":"\/ctolib\/brother\/dir1\/","filename":"file1.txt","filetype":"txt", "recordversion":"","migstatus":"resdnt","migloc":"NA","mtime":"2015-08-20T21:47:09.000Z", "atime":"2016-06-08T17:20:41.480Z","ctime":"2016-03-12T15:12:49.565Z","inserttime": "2018-10-24T04:19:37.000Z","updatedtime":"2018-10-24T04:19:37.000Z","requesttime": "2018-10-24T04:19:37.000Z","scangen":1,"tier":"system","size":28185,"qpart":0,"fkey": "ctolib.cluster1ctolib4042","collection":null,"temperature":null,"duplicate":null, "some-tag":null,"tag2":null,"tag3":null,"tag4":null,"tag5":null,"tag6":null,"tag7":null, "tag8":null,"tag9":null,"tag10":null,"tag11":null,"tag12":null,"tag13":null,"tag14":null, "tag15":null,"tag16":null}, {"datasource":"ctolib","operation":"INDEX","ingesttype":"SCAN","revision":"MO1","site": "","platform":"Spectrum Scale","cluster":"ctolib.cluster1","inode":285102,"owner":"user1", "group": "group1","permissions":"-rw-r--r--","fileset":"brother","uid":null,"gid":null, "path":"\/ctolib\/brother\/dir1\/","filename":"file2.txt","filetype":"txt", "recordversion":"","migstatus":"resdnt","migloc":"NA","mtime":"2015-08-21T00:55:33.000Z", "atime":"2016-06-24T00:51:00.797Z","ctime":"2016-03-10T22:55:06.160Z","inserttime": "2018-10-24T04:19:50.000Z","updatedtime":"2018-10-24T04:19:50.000Z","requesttime": "2018-10-24T04:19:50.000Z","scangen":1,"tier":"system","size":435947,"qpart":0,"fkey": "ctolib.cluster1ctolib28510 2","collection":null,"temperature":null,"duplicate":null, "some-tag":null,"tag2":null,"tag3":null,"tag4":null,"tag5":null,"tag6":null,"tag7":null, "tag8":null,"tag9":null,"tag10":null,"tag11":null,"tag12":null,"tag13":null,"tag14": null,"tag15":null,"tag16":null}]
- Submit the
request:
- The following example makes the same query as the preceding example but does not specify an
output format:
- Submit the
request:
curl -k -H 'Authorization: Bearer <token>' https://<spectrum_discover_host>/db2whrest/v1/sql_query?select%20*%20from%20meteor%20limit%202 -X GET"
- The following response is returned. The data is in CSV
format:
0,ctolib,INDEX,SCAN,MO1,,Spectrum Scale,ctolib.cluster1,250692,user1,group1,-rw-r--r--, brother,,,/ctolib/brother/dir1/,file1.txt,txt,,resdnt,NA,2015-08-20 11:26:29.000000, 2016-06-2323:26:00.113925,2016-03-10 19:33:36.639688,2018-10-24 04:19:50.000000, 2018-10-2404:19:50.000000,2018-10-24 04:19:50.000000,1,system,266314,0, ctolib.cluster1ctolib250692, ,,,,,,,,,,,,,,,,,, 1,ctolib,INDEX,SCAN,MO1,,Spectrum Scale,ctolib.cluster1,250662,user1,group1,-rw-r--r--, brother,,,/ctolib/brother/dir1,file2..txt,txt,,resdnt,NA,2015-08-20 11:26:25.000000 ,2016-06-23 23:25:59.990565,2016-03-10 19:33:36.070314,2018-10-24 04:19:50.000000, 2018-10-24 04:19:50.000000,2018-10-24 04:19:50.000000,1,system,305365,0, ctolib.cluster1ctolib250662, ,,,,,,,,,,,,,,,,,,
- Submit the
request: