This topic describes how to add a Tablestore data source in DataV.

  1. Log on to the DataV console.
  2. Click the Data Sources tab and then Add Source.
  3. Select TableStore from the Type drop-down list.
  4. Enter Tablestore information.
    Add a Tablestore data source
    Parameter Description
    Name The name that you want to display for the data source.
    AK ID The AccessKey ID of the account that has permissions to access the target Tablestore instance.
    AK Secret The AccessKey secret of the account that has permissions to access the target Tablestore instance.
    Internet Enter the endpoint of the target Tablestore instance. For more information, see Endpoint.
  5. After you enter the Tablestore information, click OK.

    The added data source is displayed in the data source list.

Use the Tablestore data source

  1. Log on to the DataV console.
  2. On the Projects tab, move the pointer over the project that you want to edit and click Edit.
  3. On the edit page of the canvas, click a widget.

    If no widget is added to the canvas, add a widget first. For more information, see Add a widget.

  4. In the right-side configuration pane, click the Data tab and then Set.
    Set Data Source
  5. In the Set Data Source pane, select TableStore from the Data Source Type drop-down list.
  6. In the Select Data Source section, select the configured Tablestore data source.
  7. In the Select Action section, select the operation that you want to perform.
    The system supports the following operations:
    • getRow: indicates the GetRow operation of Tablestore. For more information, see GetRow.
    • getRange: indicates the GetRange operation of Tablestore. For more information, see GetRange.
  8. In the edit box of the Select Action section, enter query statements.
    • Query parameters must be JSON objects.
    • If you select the getRow operation, a single row of data is read based on the specified primary key.

      The parameters are in the following format:

      {
      "table_name": "test",
      "rows": {
      "id": 2
      },
      "columns": [
      "id",
      "test"
      ]
      }
      Parameter Description
      table_name Enter the name of the table that you want to query.
      rows Set filter conditions to return the rows that meet the filter conditions. If you want to add columns as query conditions in the rows parameter, make sure that the columns to be added have been indexed.
      columns The names of the columns that you want to return.
    • If you select the getRange operation, a single row of data is read based on the specified primary key. The parameters are in the following format:
      {
      "table_name": "test",
      "direction": "FORWARD",
      "columns": [
      "id",
      "test"
      ],
      "range": {
      "limit": 4,
      "start": {
      "id": "InfMin"
      },
      "end": {
      "id": 3
      }
      }
      }
      Parameter Description
      table_name Enter the name of the table that you want to query.
      direction The query direction.
      columns The names of the columns that you want to return.
      limit The maximum number of rows that can be returned.
      start The start column to be read. The start column is included in the returned result and must be indexed.
      end The end column to be read. The end column is included in the returned result and must be indexed.
      Note For the start and end parameters, you can use InfMin to indicate the minimum value and use InfMax to indicate the maximum value.
  9. Click Preview Data Response to view the returned data.

Example

  1. Prepare Tablestore data.

    You must log on to the Tablestore console to create an instance and store data first. For more information, see Create an instance and Store data. The following figure creates an instance named test1948, which contains three rows of data and two columns: id(primary key, integer) and test(string).

    Tablestore data type
  2. Configure a data source.
    Configure a data source
  3. Query parameters.
    • Query data by using getRow.Query data by using getRow
      The response results are as follows.Query response results by using getRow
    • Query data by using getRange.Query data by using getRange
      The response results are as follows.Query response results by using getRange
    Note When you query data by using getRange, start is id: InfMin, and end is id: 3. Therefore, data of the row with id of 1 and the row with id of 2 is obtained. This is because getRange neither contains the end row nor the row with id of 3.