usaid-gov/feed-the-future-rwanda-interim-survey-in-the-zone-4r7p-smh6
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_rwanda_interim_survey_in_the_zone table in this repository, by referencing it like:

"usaid-gov/feed-the-future-rwanda-interim-survey-in-the-zone-4r7p-smh6:latest"."feed_the_future_rwanda_interim_survey_in_the_zone"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "g601_14_45", -- Column number 44, which corresponds to the period from 14:45 to 15:00
    "g601_21_30", -- Column number 71, which corresponds to the period from 21:30 to 21:45
    "g601_8_45", -- Column number 20, which corresponds to the period from 8:45 to 9:00
    "g601_13_30", -- Column number 39, which corresponds to the period from 13:30 to 13:45
    "g601_8_15", -- Column number 18, which corresponds to the period from 8:15 to 8:30
    "secmin", -- This is a composite measure representing the total number of minutes spent doing an activity as a secondary activity during the past 24 hour.
    "g601_22_15", -- Column number 74, which corresponds to the period from 22:15 to 22:30
    "g601_9_15", -- Column number 22, which corresponds to the period from 9:15 to 9:30
    "g601_11_30", -- Column number 31, which corresponds to the period from 11:30 to 11:45
    "g601_13_00", -- Column number 37, which corresponds to the period from 13:00 to 13:15
    "g601_23_15", -- Column number 78, which corresponds to the period from 23:15 to 23:30
    "g601_6_45", -- Column number 12, which corresponds to the period from 6:45 to 7:00
    "g601_23_30", -- Column number 79, which corresponds to the period from 23:30 to 23:45
    "g601_20_45", -- Column number 68, which corresponds to the period from 20:45 to 21:00
    "g601_16_00", -- Column number 49, which corresponds to the period from 16:00 to 16:15
    "g601_16_30", -- Column number 51, which corresponds to the period from 16:30 to 16:45
    "g601_10_45", -- Column number 28, which corresponds to the period from 10:45 to 11:00
    "g601_7_15", -- Column number 14, which corresponds to the period from 7:15 to 7:30
    "today", -- Survey Date
    "g601_10_15", -- Column number 26, which corresponds to the period from 10:15 to 10:30
    "g601_10_30", -- Column number 27, which corresponds to the period from 10:30 to 10:45
    "urbrur", -- Location type (urban rural)
    "g601_4_15", -- Column number 2, which corresponds to the period from 4:15 to 4:30
    "g601_1_45", -- Column number 88, which corresponds to the period from 1:45 to 2:00
    "g601_7_30", -- Column number 15, which corresponds to the period from 7:30 to 7:45
    "g601_13_45", -- Column number 40, which corresponds to the period from 13:45 to 14:00
    "g601_6_00", -- Column number 9, which corresponds to the period from 6:00 to 6:15
    "g601_17_45", -- Column number 56, which corresponds to the period from 17:45 to 18:00
    "g601_20_15", -- Column number 66, which corresponds to the period from 20:15 to 20:30
    "g601_15_00", -- Column number 45, which corresponds to the period from 15:00 to 15:15
    "g601_2_30", -- Column number 91, which corresponds to the period from 2:30 to 2:45
    "g601_21_45", -- Column number 72, which corresponds to the period from 21:45 to 22:00
    "g601_11_00", -- Column number 29, which corresponds to the period from 11:00 to 11:15
    "g601_3_45", -- Column number 96, which corresponds to the period from 3:45 to 4:00
    "g601_14_15", -- Column number 42, which corresponds to the period from 14:15 to 14:30
    "g601_18_45", -- Column number 60, which corresponds to the period from 18:45 to 19:00
    "g601_5_15", -- Column number 6, which corresponds to the period from 5:15 to 5:30
    "g601_9_00", -- Column number 21, which corresponds to the period from 9:00 to 9:15
    "g601_15_45", -- Column number 48, which corresponds to the period from 15:45 to 16:00
    "g601_15_30", -- Column number 47, which corresponds to the period from 15:30 to 15:45
    "g601_14_30", -- Column number 43, which corresponds to the period from 14:30 to 14:45
    "g601_18_30", -- Column number 59, which corresponds to the period from 18:30 to 18:45
    "g601_9_30", -- Column number 23, which corresponds to the period from 9:30 to 9:45
    "g601_12_30", -- Column number 35, which corresponds to the period from 12:30 to 12:45
    "g601_23_00", -- Column number 77, which corresponds to the period from 23:00 to 23:15
    "g601_12_15", -- Column number 34, which corresponds to the period from 12:15 to 12:30
    "g601_11_45", -- Column number 32, which corresponds to the period from 11:45 to 12:00
    "g601_16_15", -- Column number 50, which corresponds to the period from 16:15 to 16:30
    "g601_20_30", -- Column number 67, which corresponds to the period from 20:30 to 20:45
    "country", -- These data were collected in the Feed the Future Zone of Influence in Rwanda.
    "g601_1_15", -- Column number 86, which corresponds to the period from 1:15 to 1:30
    "g601_0_45", -- Column number 84, which corresponds to the period from 0:45 to 1:00
    "g601_3_00", -- Column number 93, which corresponds to the period from 3:00 to 3:15
    "g601_5_30", -- Column number 7, which corresponds to the period from 5:30 to 5:45
    "g601_15_15", -- Column number 46, which corresponds to the period from 15:15 to 15:30
    "g601_19_45", -- Column number 64, which corresponds to the period from 19:45 to 20:00
    "g601_2_45", -- Column number 92, which corresponds to the period from 2:45 to 3:00
    "g601_5_45", -- Column number 8, which corresponds to the period from 5:45 to 6:00
    "g601_18_00", -- Column number 57, which corresponds to the period from 18:00 to 18:15
    "g601_0_30", -- Column number 83, which corresponds to the period from 0:30 to 0:45
    "g601_17_00", -- Column number 53, which corresponds to the period from 17:00 to 17:15
    "g601_13_15", -- Column number 38, which corresponds to the period from 13:15 to 13:30
    "g601_1_00", -- Column number 85, which corresponds to the period from 1:00 to 1:15
    "g601_4_45", -- Column number 4, which corresponds to the period from 4:45 to 5:00
    "acode", -- Module G6(A) activity code
    "g601_21_15", -- Column number 70, which corresponds to the period from 21:15 to 21:30
    "g601_4_00", -- Column number 1, which corresponds to the period from 4:00 to 4:15
    "g601_20_00", -- Column number 65, which corresponds to the period from 20:00 to 20:15
    "g601_3_15", -- Column number 94, which corresponds to the period from 3:15 to 3:30
    "g601_23_45", -- Column number 80, which corresponds to the period from 23:45 to 0:00
    "g601_19_30", -- Column number 63, which corresponds to the period from 19:30 to 19:45
    "g601_17_15", -- Column number 54, which corresponds to the period from 17:15 to 17:30
    "g601_22_45", -- Column number 76, which corresponds to the period from 22:45 to 23:00
    "g601_0_15", -- Column number 82, which corresponds to the period from 0:15 to 0:30
    "cluster", -- Cluster number
    "g601_3_30", -- Column number 95, which corresponds to the period from 3:30 to 3:45
    "survey", -- These data were collected in the 2015 Interim Zone of Influence Survey.
    "weai_wt", -- Individual sampling weight for primary female decisionmakers
    "primemin", -- This is a composite measure representing the total number of minutes spent doing an activity as a primary activity during the past 24 hour.
    "g601_21_00", -- Column number 69, which corresponds to the period from 21:00 to 21:15
    "g601_7_00", -- Column number 13, which corresponds to the period from 7:00 to 7:15
    "g601_22_30", -- Column number 75, which corresponds to the period from 22:30 to 22:45
    "g601_22_00", -- Column number 73, which corresponds to the period from 22:00 to 22:15
    "secmintt", -- This is the total number of secondary minutes of activity performed by a person. The number will not vary across activities. The values should fall between 0 and 1440.
    "g601_14_00", -- Column number 41, which corresponds to the period from 14:00 to 14:15
    "g601_8_30", -- Column number 19, which corresponds to the period from 8:30 to 8:45
    "g601_2_15", -- Column number 90, which corresponds to the period from 2:15 to 2:30
    "g601_4_30", -- Column number 3, which corresponds to the period from 4:30 to 4:45
    "g601_12_00", -- Column number 33, which corresponds to the period from 12:00 to 12:15
    "prmmintt", -- This is the total number of primary minutes of activity performed by a person. The number will not vary across activities. All values should be 1440. If not 1440, prepare a tabulation of the minutes for review.
    "g601_7_45", -- Column number 16, which corresponds to the period from 7:45 to 8:00
    "g601_2_00", -- Column number 89, which corresponds to the period from 2:00 to 2:15
    "g601_1_30", -- Column number 87, which corresponds to the period from 1:30 to 1:45
    "g601_19_15", -- Column number 62, which corresponds to the period from 19:15 to 19:30
    "g601_17_30", -- Column number 55, which corresponds to the period from 17:30 to 17:45
    "g601_10_00", -- Column number 25, which corresponds to the period from 10:00 to 10:15
    "g601_18_15", -- Column number 58, which corresponds to the period from 18:15 to 18:30
    "g601_16_45", -- Column number 52, which corresponds to the period from 16:45 to 17:00
    "idcode", -- Woman s ID code
    "g601_6_30", -- Column number 11, which corresponds to the period from 6:30 to 6:45
    "stratum", -- Administrative variable for identifying the strata of sampling designs. Unstratified samples have a constant value of 1.
    "g601_19_00", -- Column number 61, which corresponds to the period from 19:00 to 19:15
    "g601_5_00", -- Column number 5, which corresponds to the period from 5:00 to 5:15
    "pbs_id", -- Administrative variable for identifying households
    "g601", -- Now I d like to ask you about how you spent your time during the past 24 hours. This will be a detailed accounting. We ll begin from yesterday morning at 4am, and continue through 4am of this morning.
    "g601_9_45", -- Column number 24, which corresponds to the period from 9:45 to 10:00
    "g601_6_15", -- Column number 10, which corresponds to the period from 6:15 to 6:30
    "activity", -- Module G6(A) activity
    "g601_12_45", -- Column number 36, which corresponds to the period from 12:45 to 13:00
    "g601_8_00", -- Column number 17, which corresponds to the period from 8:00 to 8:15
    "g601_0_00", -- Column number 81, which corresponds to the period from 0:00 to 0:15
    "g601_11_15" -- Column number 30, which corresponds to the period from 11:15 to 11:30
FROM
    "usaid-gov/feed-the-future-rwanda-interim-survey-in-the-zone-4r7p-smh6:latest"."feed_the_future_rwanda_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-rwanda-interim-survey-in-the-zone-4r7p-smh6 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-rwanda-interim-survey-in-the-zone-4r7p-smh6: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-rwanda-interim-survey-in-the-zone-4r7p-smh6

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-rwanda-interim-survey-in-the-zone-4r7p-smh6:latest

This will download all the objects for the latest tag of usaid-gov/feed-the-future-rwanda-interim-survey-in-the-zone-4r7p-smh6 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-rwanda-interim-survey-in-the-zone-4r7p-smh6: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-rwanda-interim-survey-in-the-zone-4r7p-smh6: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-rwanda-interim-survey-in-the-zone-4r7p-smh6 is just another Postgres schema.

Related Documentation:

Loading...