usaid-gov/baseline-study-of-food-for-peace-title-ii-cvza-mwy2
Icon for Socrata external plugin

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 baseline_study_of_food_for_peace_title_ii table in this repository, by referencing it like:

"usaid-gov/baseline-study-of-food-for-peace-title-ii-cvza-mwy2:latest"."baseline_study_of_food_for_peace_title_ii"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "a04b", -- A04b DEPARTMENT NAME
    "cf", -- Eggs
    "c00h", -- MODULE C START HOUR
    "c01c", -- C01C LINE NUMBER FROM HOUSEHOLD ROSTER COLUMN 6
    "pvo", -- PVO
    "f10_2", -- F10 2 Do you do anything to the water to make it safer to drink
    "f10_8", -- F10 8 Do you do anything to the water to make it safer to drink
    "c09", -- C09 Any eggs
    "e19", -- E19 Any eggs
    "c17", -- C17 How often did this happen in the past 4 weeks
    "hhs_n2", -- Household Hunger Scale moderate and severe hunger
    "e27", -- E27 Any foods made with red palm oil red palm nut or red palm nut pulp sauce
    "ca", -- Cereals
    "f08", -- F08 In the last two weeks was water available from this source for an entire day or longer
    "c18", -- C18 In the past 4 weeks did anyone go to sleep hungry because there was not enough food
    "f10_4", -- F10 4 Do you do anything to the water to make it safer to drink
    "c12", -- C12 Any cheese yogurt milk or other milk products
    "c14", -- C14 Any sugar or honey
    "e00m", -- MODULE E START MINUTE
    "e03a", -- E03A In what month were you born
    "e05", -- E05 Are you between the ages of 15 49 yrs
    "cj", -- Oil fats
    "ci", -- Milk and milk products
    "e11", -- E11 Any foods made from grains
    "e14", -- E14 Any dark green leafy vegetables
    "e16", -- E16 Any other fruit or vegetables
    "e26", -- E26 Any grubs snails or insects
    "cd", -- Fruits
    "cc", -- Vegetables
    "e29", -- E29 Have you ever been pregnant
    "cb", -- Root and tubers
    "e31m", -- E31M When was the last time you gave birth MONTH
    "wmwt", -- Sampling weight for women 15 49 adjusted for module E non response
    "hhwt", -- Sampling weight for households and household members
    "e34", -- E34 ANTHROPOMETRY LINE NUMBER OF WOMAN FROM ROSTER
    "e39", -- E39 RESULT
    "at_vn", -- ANTHRO VILLAGE NUMBER
    "at_sm", -- ANTHRO START MINUTE
    "at_any", -- Anthropometry date Year
    "i200h", -- MODULE I2 START HOUR
    "gendered_hh", -- Gendered Household type
    "ce", -- Meats organs blood
    "c1617", -- No food at all in the house
    "id",
    "hh", -- A01 HOUSEHOLD NUMBER
    "vn", -- A02 VILLAGE NUMBER
    "a04a", -- A04a COMMUNE NAME
    "a13d", -- DAY OF FINAL VISIT
    "a13m", -- MONTH OF FINAL VISIT
    "a13in", -- INTERVIEWER NUMBER FOR FINAL VISIT
    "a14_1", -- A14 1 Total Number of Visits
    "a14_2", -- A14 2 Total Women 15 49 yrs
    "a14_3", -- A14 3 Total Eligible Farmers
    "a14_4", -- A14 4 Total Children Under 5
    "a14_5", -- A14 5 Line Number of Respondant to Household Questionnaire
    "a19", -- A19 OFFICE EDITOR CODE
    "delivery_lapse", -- Time since last delivery in days
    "del_date", -- Date of last delivery
    "wom_age", -- Women s age in completed years
    "birth_date", -- Woman s date of birth
    "a20d", -- A20 DAY OF DATA ENTRY
    "b00h", -- MODULE B START HOUR
    "int_date", -- Date of Interview
    "cluster", -- Cluster
    "strata", -- Strata
    "e06", -- E06 CHECK AGE IS BETWEEN 15 49 YRS
    "e00h", -- MODULE E START HOUR
    "b21m", -- MODULE B FINISH MINUTE
    "f00h", -- MODULE F START HOUR
    "f00m", -- MODULE F START MINUTE
    "f01a", -- F01A HOUSEHOLD NUMBER
    "f02", -- F02 LINE NUMBER OF RESPONDENT
    "f04", -- F04 What is main source of drinking water
    "f05", -- F05 Where is that water source located
    "f06", -- F06 How long does it take to go there get water and come back
    "f07", -- F07 Is water available from this source all year round
    "h01m", -- H01M MODULE H FINISH MINUTE
    "h01h", -- H01H MODULE H FINISH HOUR
    "h00m", -- H00M MODULE H START MINUTE
    "h00h", -- H00H MODULE H START HOUR
    "f17_2", -- F17 List five critical moments for handwashing
    "i208m", -- MODULE I2 FINISH MINUTE
    "a17", -- A17 SUPERVISOR CODE
    "f10_3", -- F10 3 Do you do anything to the water to make it safer to drink
    "f10_5", -- F10 5 Do you do anything to the water to make it safer to drink
    "f12", -- F12 Does your household share the toilet facility with other households
    "f13", -- F13 How many households share the toilet facility
    "f14", -- F14 Show me where members of your household most often wash their hands
    "c06", -- C06 Any vegetables
    "f17_1", -- F17 List five critical moments for handwashing
    "f17_4", -- F17 List five critical moments for handwashing
    "f17_5", -- F17 List five critical moments for handwashing
    "f17_8", -- F17 List five critical moments for handwashing
    "g70h", -- MODULE G FINISH HOUR
    "g70m", -- MODULE G FINISH MINUTE
    "c00m", -- MODULE C START MINUTE
    "e21", -- E21 Any foods made from beans or seeds
    "i208h", -- MODULE I2 FINISH HOUR
    "i200m", -- MODULE I2 START MINUTE
    "at_fm", -- ANTHRO FINISH MINUTE
    "f18h", -- MODULE F FINISH HOUR
    "e25", -- E25 Any condiments such as chilies spices herbs or fish powder
    "a14", -- A14 FINAL OUTCOME OF INTERVIEW
    "at_anm", -- Anthropometry date Month
    "at_fh", -- ANTHRO FINISH HOUR
    "c01a", -- C01A HOUSEHOLD NUMBER
    "c01b", -- C01B VILLAGE NUMBER
    "c02", -- C02 Was yesterday an unusual or special day
    "c04", -- C04 Any foods made from wheat maize rice sorghum or millet
    "at_and", -- Anthropometry date Day
    "at_sh", -- ANTHRO START HOUR
    "at_hh", -- ANTHRO HOUSEHOLD NUMBER
    "at_id", -- ANTHRO QUESTIONNAIRE NUMBER
    "i110m", -- MODULE I1 FINISH MINUTE
    "i110h", -- MODULE I1 FINISH HOUR
    "i100m", -- MODULE I1 START MINUTE
    "c07", -- C07 Any fruits
    "c08", -- C08 Any meats organ meats or blood
    "i100h", -- MODULE I1 START HOUR
    "e38", -- E38 WOMAN S WEIGHT KILOGRAMS
    "e37", -- E37 WOMAN S HEIGHT CENTIMETERS
    "e36", -- E36 WOMAN S AGE IN YEARS
    "e33m", -- MODULE E FINISH MINUTE
    "e33h", -- MODULE E FINISH HOUR
    "e31d", -- E31D When was the last time you gave birth DAY
    "e30", -- E30 Have you ever given birth
    "e28", -- E28 Are you currently pregnant
    "e15", -- E15 Any ripe mangos papayas melon or passionfruit
    "e13", -- E13 Potatoes or any other foods made from roots
    "e12", -- E12 Any foods that are yellow or orange inside
    "e04", -- E04 How old are you
    "e03b", -- E03B In what year were you born
    "e02", -- E02 LINE NUMBER OF WOMAN FROM HOUSEHOLD ROSTER
    "e01b", -- E01B VILLAGE NUMBER
    "e01a", -- E01A HOUSEHOLD NUMBER
    "d66m", -- MODULE D FINISH MINUTE
    "d66h", -- MODULE D FINISH HOUR
    "d00m", -- MODULE D START MINUTE
    "a18", -- A18 FIELD COORDINATOR CODE
    "f17_10", -- F17 List five critical moments for handwashing
    "c19", -- C19 How often did this happen in the last 4 weeks
    "c21", -- C21 How often did this happen in the last 4 weeks
    "a13y", -- YEAR OF FINAL VISIT
    "e17", -- E17 Any liver kidney heart or other organ meats blood
    "f10_6", -- F10 6 Do you do anything to the water to make it safer to drink
    "c2021", -- Went all day and night without eating
    "a20y", -- A20 YEAR OF DATA ENTRY
    "c10", -- C10 Any fresh or dried fish or shellfish
    "c15", -- C15 Any other foods such as condiments coffee or tea
    "c16", -- C16 In the past 4 weeks was there ever no food to eat due to lack of resources
    "c20", -- C20 In the past 4 weeks did anyone go a whole day and night without eating because there was no food
    "c22h", -- MODULE C FINISH HOUR
    "c22m", -- MODULE C FINISH MINUTE
    "d00h", -- MODULE D START HOUR
    "ch", -- Pulses legumes nuts
    "c05", -- C05 Any foods made from roots or tubers
    "critical_handwashing_all", -- Knows all 5 critical moments for handwashing
    "critical_handwashing_cat", -- Knows 3 of 5 critical moments for handwashing
    "critical_handwashing", -- Number of critical moments for handwashing known out of 5
    "soap_water", -- Cleansing agent and water at handwashing station
    "improved_source", -- Households using an improved drinking water source
    "improved_sanitation", -- Households using improved sanitation facilities
    "f10_9", -- F10 9 Do you do anything to the water to make it safer to drink
    "hhs_n", -- Household Hunger Scale moderate or severe hunger
    "cl", -- Miscellaneous
    "hhs", -- Household Hunger Scale
    "c1819", -- Went to bed hungry
    "wom_count", -- Number of women interviewed in household per MOD E E02
    "cg", -- Fish and seafood
    "e18", -- E18 Any meat
    "e22", -- E22 Any cheese yogurt or other milk products
    "e23", -- E23 Any foods made with oils fats or butter
    "e24", -- E24 Any sugary foods such as chocolate and cake
    "eligible_women", -- Women eligible for Module E between 15 and 49 years of age
    "f15", -- F15 Observe presence of water at the place of handwashing
    "reg", -- A05 REGION
    "c11", -- C11 Any foods made from beans nuts or seeds
    "e20", -- E20 Any fish or seafood
    "ck", -- Sugar honey
    "f17_3", -- F17 List five critical moments for handwashing
    "a20", -- A20 DATA ENTRY OPERATOR CODE
    "a20m", -- A20 MONTH OF DATA ENTRY
    "b00m", -- MODULE B START MINUTE
    "b21h", -- MODULE B FINISH HOUR
    "f01b", -- F01B VILLAGE NUMBER
    "f09", -- F09 Do you do anything to the water to make it safer to drink
    "f10_1", -- F10 1 Do you do anything to the water to make it safer to drink
    "f10_7", -- F10 7 Do you do anything to the water to make it safer to drink
    "f11", -- F11 What kind of toilet facility do members of your household usually use
    "f16", -- F16 Observe presence of soap detergent or other cleansing agent at the place for handwashing
    "f17_6", -- F17 List five critical moments for handwashing
    "f17_7", -- F17 List five critical moments for handwashing
    "e31y", -- E31Y When was the last time you gave birth YEAR
    "f17_9", -- F17 List five critical moments for handwashing
    "f18m", -- MODULE F FINISH MINUTE
    "g00h", -- MODULE G START HOUR
    "g00m", -- MODULE G START MINUTE
    "hdds", -- Average Household Dietary Diversity Score HDDS
    "c13", -- C13 Any foods made with oil fat or butter
    "women_id" -- member ID for module E
FROM
    "usaid-gov/baseline-study-of-food-for-peace-title-ii-cvza-mwy2:latest"."baseline_study_of_food_for_peace_title_ii"
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/baseline-study-of-food-for-peace-title-ii-cvza-mwy2 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.usaid.gov. When you queryusaid-gov/baseline-study-of-food-for-peace-title-ii-cvza-mwy2:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

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 (like this repository), 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, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.usaid.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "usaid-gov/baseline-study-of-food-for-peace-title-ii-cvza-mwy2" \
  --handler-options '{
    "domain": "data.usaid.gov",
    "tables": {
        "baseline_study_of_food_for_peace_title_ii": "cvza-mwy2"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

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/baseline-study-of-food-for-peace-title-ii-cvza-mwy2 is just another Postgres schema.