Pulse
Allows kdb developers to easily create real-time interactive dashboards direct from kdb data.
Allows kdb developers to easily create real-time interactive dashboards direct from kdb data.
Kdb+ provides a basic implementation of a web server allowing browsing tables that exist on the server, performing queries and downloading data from a web browser. Kdb+ also provides calls to pull data via HTTP. We'll examing how to do this below:
To connect to a kdb+ server:
q -p 5000
To send a custom query to the server we use a /?
followed by our query as shown:
If you insert a filename with the ending .csv
, .xls
or .xml
this will download a file for that query from the server in either csv/excel format.
When an HTTP GET request is received, the request is processed by the .z.ph event handler.
The argument it receives is a two item list of the form: ( request text ; request header )
. Here I have saved it to a variable a:
You can override this function to provide your own html interface. Here's an example where we override .z.ph to provide a qStudio like web interface:
Similarly there is a .z.pp event handler for HTTP post events.
From kdb+ we can send HTTP requests to webservers. For example we can send a request to yahoo finance servers for a csv file they provide:
Let's wrap our http get in a function and then parse our data so we get a table:
This http querying works for any type of page, even plain webpages, and could be used to query REST api's etc.