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