0

Planning a vacation with Splitgraph and Observable

 2 years ago
source link: https://www.splitgraph.com/blog/observable-query-oxford-covid
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Apr 28, 2022 · By Peter Neumark
READING TIME: 1 min

Planning a vacation with Splitgraph and Observable

Query public Splitgraph repositories from Observable notebooks, by importing the Splitgraph Observable Client to send SQL queries over HTTP to the Splitgraph Data Delivery Network (DDN).

Query Splitgraph from Public Observable Notebooks

Observable has native support for connecting to PostgreSQL from private notebooks and querying SQLite files from public notebooks. Unfortunately, querying large amounts of data from public notebooks has not been supported.

That's changed now thanks to the Splitgraph Observable Client, which lets you query all the public data on the Splitgraph Data Delivery Network (DDN) from any notebook.

Import the client

To use the Splitgraph Observable Client in your own notebook, simply import it from the @splitgraph/ddn notebook. Call the splitgraph function to send SQL queries to the DDN over its HTTP API:

import { splitgraph } from "@splitgraph/ddn"

all_cases = await splitgraph`
SELECT
  date,
  confirmed,
  recovered,
  dead,
  source
FROM "splitgraph/oxcovid19".epidemiology
WHERE countrycode = 'GBR' AND gid = '{"GBR"}' AND source = 'GBR_PHE'
ORDER BY date DESC`

Example notebook

This Planning a family vacation notebook showcases the Observable Splitgraph API:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK