usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y
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 feed_the_future_zambia_interim_survey_in_the_zone table in this repository, by referencing it like:

"usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y:latest"."feed_the_future_zambia_interim_survey_in_the_zone"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "h40", -- H40: last time age special sweet potato
    "h20a", -- H20A: Consumed - flesh meat of wild animal
    "h28_p", -- H28: Prompted - spices herbs
    "h20a_p", -- H20A: Prompted - flesh meat of wild animal
    "idcode", -- Individual identifier
    "w_foodmiss", -- Indicates the woman is missing all food questions
    "h18_p", -- H18: Prompted - dark yellow, orange fruit
    "w_nrvcc3", -- Consumed NRVCC pigeon peas
    "h30", -- H30: Consumed - red palm products
    "h30_p", -- H30: Prompted - red palm products
    "h38", -- H38: planted special sweet potato
    "w_meatfish", -- Flesh foods including organ meat and small animal protein
    "w_othfrt", -- Other fruits
    "h19_p", -- H19: Prompted - organ meat of domesticated animal
    "h14_p", -- H14: Prompted - grains
    "h06", -- H06: Currently pregnant
    "h07", -- H07: Weight (kgs)
    "h24c_p", -- H24C: Prompted - groundnuts
    "h17_p", -- H17: Prompted - local dark green leafy vegetables
    "h23_p", -- H23: Prompted - fish seafood
    "w_othveg", -- Other vegetables
    "h24e", -- H24E: Consumed - nuts seeds
    "w_foodsum9", -- Womens Dietary Diversity Score - 9 groups (WDDS)
    "h28", -- H28: Consumed - spices herbs
    "h24c", -- H24C: Consumed - groundnuts
    "h24a_p", -- H24A: Prompted - pigeon peas
    "w_mdd", -- Women consumed minimum dietary diversity (MDD-W)
    "h24a", -- H24A: Consumed - pigeon peas
    "h23", -- H23: Consumed - fish seafood
    "h19a", -- H19A: Consumed - flesh meat of domesticated animal
    "h24b", -- H24B: Consumed - cow peas
    "urbrur", -- DERIVED: Location type (urban rural)
    "h33", -- H33: planted special maize
    "h24_p", -- H24: Prompted - soy or soy products
    "h24d_p", -- H24D: Prompted - other beans legumes
    "w_nrvcc7", -- Consumed NRVCC orange maize
    "h27", -- H27: Consumed - sugary foods
    "w_nutsbeans", -- Legumes, beans, nuts and seeds
    "w_nrvcc6", -- Consumed NRVCC local dark green leafy vegetables
    "h34", -- H34: eaten special maize
    "h14", -- H14: Consumed - grains
    "bmicat", -- BMI category
    "underwght", -- Underweight (BMI 18.5) among non-pregnant WRA
    "cluster", -- A02: Cluster
    "today", -- ODK: Survey Date
    "w_nrvcc1", -- Consumed NRVCC groundnuts
    "h32", -- H32: obtained special maize from
    "bmi", -- Women s BMI (weight in kg (height in m squared))
    "height", -- height (m)
    "h18a", -- H18A: Consumed - other fruits
    "h16_p", -- H16: Prompted - roots tubers
    "h08", -- H08: Height (cms)
    "h02_y", -- H02: Year of birth
    "h04", -- H04: Between 15 and 49?
    "h25", -- H25: Consumed - dairy
    "country", -- DERIVED: Country
    "h17b_p", -- H17B: Prompted - other vegetables
    "h35", -- H35: last time age special maize
    "h17a_p", -- H17A: Prompted - other dark green leafy vegetables
    "h19", -- H19: Consumed - organ meat of domesticated animal
    "h17", -- H17: Consumed - local dark green leafy vegetables
    "survey", -- DERIVED: Survey
    "h26_p", -- H26: Prompted - fats
    "h27_p", -- H27: Prompted - sugary foods
    "h17a", -- H17A: Consumed - other dark green leafy vegetables
    "h15_p", -- H15: Prompted - yellow orange foods
    "h17b", -- H17B: Consumed - other vegetables
    "w_nrvcc5", -- Consumed NRVCC orange-fleshed sweet potatoes
    "stratum", -- DERIVED: Stratum
    "w_beans", -- Legumes and beans
    "h31", -- H31: heard of special maize
    "h24", -- H24: Consumed - soy or soy products
    "h18a_p", -- H18A: Prompted - other fruits
    "h37", -- H37: obtained special sweet potato from
    "w_othfrtveg", -- Other fruits and vegetables
    "pbs_id", -- A01: Household ID
    "w_nuts", -- Nuts and seeds
    "h18", -- H18: Consumed - dark yellow, orange fruit
    "np_wrasample", -- Indicates the woman is aged 15-49 years and not pregnant
    "zoi", -- ZOI
    "h22", -- H22: Consumed - eggs
    "h39", -- H39: eaten special sweet potato
    "h20_p", -- H20: Prompted - organ meat of wild animal
    "h29", -- H29: Consumed - insects snails
    "w_vita", -- Other Vitamin A rich vegetables and fruits
    "weight", -- weight (kg)
    "w_nrvcc_any", -- Consumed any NRVCC
    "h25_p", -- H25: Prompted - dairy
    "h15", -- H15: Consumed - yellow orange foods
    "h24d", -- H24D: Consumed - other beans legumes
    "h03", -- H03: Age in years
    "w_eggs", -- Eggs
    "h19a_p", -- H19A: Prompted - flesh meat of domesticated animal
    "w_nrvcc2", -- Consumed NRVCC soy or soy products
    "w_organmeat", -- Organ meat
    "h16", -- H16: Consumed - roots tubers
    "wrasample", -- Indicates the woman is aged 15-49 years
    "h20", -- H20: Consumed - organ meat of wild animal
    "w_grains", -- Grains, roots and tubers
    "women_wt", -- Zambia Women sampling weight
    "h02_m", -- H02: Month of birth
    "h24b_p", -- H24B: Prompted - cow peas
    "h24e_p", -- H24E: Prompted - nuts seeds
    "w_lfygrn", -- Vitamin A rich dark green leafy vegetables
    "h29_p", -- H29: Prompted - insects snails
    "w_flesh", -- Flesh foods and other misc. small animal protein
    "w_nrvcc4", -- Consumed NRVCC cow peas
    "w_dairy", -- Dairy products
    "h22_p", -- H22: Prompted - eggs
    "w_foodsum10", -- Womens Minimum Dietary Diversity Score - 10 groups
    "h36", -- H36: heard of special sweet potato
    "h26" -- H26: Consumed - fats
FROM
    "usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y:latest"."feed_the_future_zambia_interim_survey_in_the_zone"
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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y 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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y: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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y

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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y:latest

This will download all the objects for the latest tag of usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y 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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y: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 usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y: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, usaid-gov/feed-the-future-zambia-interim-survey-in-the-zone-5sjt-ah9y is just another Postgres schema.

Related Documentation:

Loading...