当前位置:网站首页>Redash connects to dolphin DB data source

Redash connects to dolphin DB data source

2020-12-07 18:53:40 Dolphin DB technology

Redash It's an open source BI Tools , Provides the basis for Web Database query and visualization function of .DolphinDB Supported by https Agreed POST and GET Interface to get data , have access to Redash Medium JSON and URL Two data sources to connect DolphinDB.

1. Use JSON Data source connection DolphinDB

Redash At present, there is only an online version (SAAS) Chinese support JSON, So users of the online version can choose this connection . This way requires DolphinDB Internet access . To use Redash edition , Need to be in Redash Register on the official website and log in .

After logging in , Create a data source on the home page , Follow the steps below to configure :

(1) Building new data sources

 Insert picture description here (2) choice JSON data source

 Insert picture description here (3) stay Name Configure data source name in , And save
 Insert picture description here
(4) Click on Create Button , Create a Query
 Insert picture description here
JSON Data sources need to use yaml formatting .

query There are three basic elements that need to be included in :url, method and json.

  • url: The address that receives the data , namely DolphinDB Data nodes , Such as http://host:port
  • method:http submission ,JSON Interface must be used POST The way
  • json: The submitted JSON data ,DolphinDB Interfaces need to provide fixed key value client and queries, Such as :{client:“redash”,“queries”:"[sql query]"}, Users can use whatever sql Statement to replace [sql query] part .

complete query Examples are as follows :

 url: http://115.239.209.226:18531
 method: "post"
 json: {'client':'redash','queries':'select * from typeTable'}
  • 1
  • 2
  • 3

2. Use URL Data source connection DolphinDB

redash Of url Data sources support more than just online versions , It can also be supported on open source independent deployment versions . therefore , Users using stand-alone deployment can connect in this way DolphinDB.

How to connect and configure data sources with JSON In basically the same way , Select when selecting data sources URL Type data source , Here's the picture :
 Insert picture description here stay URL Configure the data source name and path in ,URL base path It's the address to get the data , configure DolphinDB The address of the data node of , The format is http://host:port.

 Insert picture description here Create a new query, In the edit area, use URL Input the query content in the form of parameter string , Query content format has the following requirements :

  • The subpath must be /json.
  • query Parameters must contain : client and queries Two key, among client Specify a fixed value of redash

complete query Examples are as follows :

/json?client=redash&queries=select * from typeTable where id between (1..10)

Be careful :
because redash Yes url The parameters of the mode should be coded and checked , So some special characters need to be done by hand url Code to pass the verification , such as query It appears that ://,+,& These characters , Need to be replaced with %3a%2f%2f,%2b,%26 Can pass the verification . for instance ,DolphinDB In the distributed database dfs://dbpath, Need to use url Replace the code with dfs%3a%2f%2fdbpath Can pass redash The check .

Need to submit query:

/json?client=redash&queries=login('admin','123456');select avg(ofr-bid) from loadTable('dfs://TAQ','quotes') group by minute(time) as minute

Actually write redash The content in the editor of is :

/json?client=redash&queries=login('admin','123456');select avg(ofr-bid) from loadTable('dfs%3a%2f%2fTAQ','quotes') group by minute(time) as minute

版权声明
本文为[Dolphin DB technology]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207184532580a.html