cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9
Loading...

Query the Data Delivery Network

Query the DDN

The easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432 and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.

For example, you can query the neighborhood_financial_health_digital_mapping_and table in this repository, by referencing it like:

"cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest"."neighborhood_financial_health_digital_mapping_and"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "ind4outcome", -- The outcome, or raw score, for the fourth indicator for each goal
    "ind8rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind8outcome", -- The outcome, or raw score, for the eighth indicator for each goal
    "ind7rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind7outcome", -- The outcome, or raw score, for the seventh indicator for each goal
    "ind6rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind5rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind5outcome", -- The outcome, or raw score, for the fifth indicator for each goal
    "ind4", -- The name of the fourth indicator for each goal
    "ind3rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind3outcome", -- The outcome, or raw score, for the third indicator for each goal
    "ind2outcome", -- The outcome, or raw score, for the second indicator for each goal
    "ind1definition", -- Narrative definition of the first indicator for each goal
    "ind1outcome", -- The outcome, or raw score, for the first indicator for each goal
    "indexscore", -- The index score of the PUMA.
    "goalrank", -- The PUMA's total outcome ranked against all NYC PUMAs for the specified goal.
    "goalname", -- The short name of the goal with presentation label
    "goal", -- The short name of the Financial Health goal.  
    "perc_hispanic", -- The percent of the population in the PUMA that is Hispanic
    "perc_black", -- The percent of the population in the PUMA that is black
    "perc_white", -- The percent of the population in the PUMA that is white
    "neighborhoods", -- Name of the Neighborhood Tabulation Area (NTA)
    "ind2definition", -- Narrative definition of the second indicator for each goal
    "ind1rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "perc_other", -- The percent of the population in the PUMA that is of other race/ethnicity
    "ind8", -- The name of the eighth indicator for each goal
    "ind6outcome", -- The outcome, or raw score, for the sixth indicator for each goal
    "ind3definition", -- Narrative definition of the third indicator for each goal
    "ind2rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "median_income", -- The median income in the PUMA
    "join", -- A value included in the dataset for recursive processing for the map visualization - a self-join on the dataset by PUMA
    "ind7definition", -- Narrative definition of the seventh indicator for each goal
    "ind7", -- The name of the seventh indicator for each goal
    "ind6definition", -- Narrative definition of the sixth indicator for each goal
    "ind6", -- The name of the sixth indicator for each goal
    "ind5definition", -- Narrative definition of the fifth indicator for each goal
    "ind5", -- The name of the fifth indicator for each goal
    "ind4definition", -- Narrative definition of the fourth indicator for each goal
    "ind4rank", -- Where the PUMA's score for the goal's indicator ranks among all PUMAs for that indicator
    "ind3", -- The name of the third indicator for each goal
    "ind2", -- The name of the second indicator for each goal
    "ind1", -- The name of the first indicator for each goal
    "scorerank", -- The index score's rank among all PUMAs
    "totaloutcome", -- Also referred to as the indicator score.  
    "goalfullname", -- The full name of the goal with presentation label
    "perc_asian", -- The percent of the population in the PUMA that is Asian
    "nyc_poverty_rate", -- The poverty rate of the PUMA
    "cd", -- Community District(s) that comprise the PUMA
    "borough", -- NYC Borough
    "puma", -- Public Use Microdata Areas (PUMAs) are non-overlapping, statistical geographic areas that partition each state or equivalent entity into geographic areas containing no fewer than 100,000 people each
    "year_published", -- The year DCWP published the dataset.
    "ind8definition" -- Narrative definition of the eighth indicator for each goal
FROM
    "cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest"."neighborhood_financial_health_digital_mapping_and"
LIMIT 100;

Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9 with SQL in under 60 seconds.

Query Your Local Engine

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
 

Read the installation docs.

Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.

It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgrcan manage the image, container and volume for you.

There are a few ways to ingest data into the local engine.

For external repositories, the Splitgraph Engine can "mount" upstream data sources by using sgr mount. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.

For hosted datasets (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Cloning Data

Because cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.

First, install Splitgraph if you haven't already.

Clone the metadata with sgr clone

This will be quick, and does not download the actual data.

sgr clone cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9

Checkout the data

Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest tag:

sgr checkout cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest

This will download all the objects for the latest tag of cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9 and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.

Alternatively, use "layered checkout" to avoid downloading all the data

The data in cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:

sgr checkout --layered cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9:latest

This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.

Read the layered querying documentation to learn about when and why you might want to use layered queries.

Query the data with your existing tools

Once you've loaded the data into your local Splitgraph Engine, you can query it with any of your existing tools. As far as they're concerned, cityofnewyork-us/neighborhood-financial-health-digital-mapping-and-r3dx-pew9 is just another Postgres schema.

Related Documentation:

Loading...