usaid-gov/data-on-agricultural-practices-in-segamil-and-iez5-p5fw
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 data_on_agricultural_practices_in_segamil_and table in this repository, by referencing it like:

"usaid-gov/data-on-agricultural-practices-in-segamil-and-iez5-p5fw:latest"."data_on_agricultural_practices_in_segamil_and"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "g55_total_3", -- Sustainable NRM practices Reforestaci n nuevas plantaciones
    "improved_storage", -- Farmers who used improved storage practices for corn CRS and SAVE or beans SAVE in the past 12 months
    "value_chain_any", -- Value chain activities any
    "g81_8", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g76_5", -- G76 Where sold their products in the last 12 months
    "market_production", -- Market oriented production
    "goat_management_cat", -- Management of goats 3 of 4 deworming vaccination hoof removal vitamin supplementation
    "g74_4", -- G74 What kind of problems have you had in the business
    "g74_10", -- G74 What kind of problems have you had in the business
    "g81_7", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g72_4", -- G72 What were the organizations that provided loans for business
    "g55_total_2", -- Sustainable NRM practices Manejo de Regeneraci n natural
    "native_herbs", -- Production of native herbs
    "native_corn", -- Use of native corn seed semilla criolla
    "g62_total_2", -- Managemant of goats Vitamin supplementation
    "g70a", -- G70A In the past year have made calculations of business expenses
    "g76_9", -- G76 Where sold their products in the last 12 months
    "organic_fertilization", -- Use of organic fertilization practices
    "id",
    "g74_2", -- G74 What kind of problems have you had in the business
    "insurance", -- Had agricultural insurance in the last 12 months
    "g81_10", -- G81 What where the organizations or savings groups you used in the last 12 months
    "pvo", -- PVO
    "financial_services", -- Farmers who used any financial services in the past 12 months
    "g78", -- G78 Agricultural insurance in the last 12 months
    "g55_total_5", -- Sustainable NRM practices Manejo de plantaciones forestales
    "credit", -- Obtained an agricultural credit in the last 12 months
    "num_farmers", -- Number of farmers interviewed in the household
    "sustainable_agriculture_cat", -- Farmers who used at least two sustainable agricultural practices and or technologies crop livestock and NRM in the past twelve months
    "g80", -- G80 Did you have the support of an institution or savings group
    "g71", -- G71 In the past year have had the support of an institution for loans
    "g74_7", -- G74 What kind of problems have you had in the business
    "g76_3", -- G76 Where sold their products in the last 12 months
    "livestock_any", -- Sustainable livestock practices any
    "g76_6", -- G76 Where sold their products in the last 12 months
    "g76_10", -- G76 Where sold their products in the last 12 months
    "production_plan", -- Developing production and sales plans
    "g72_7", -- G72 What were the organizations that provided loans for business
    "sustainable_livestock", -- Number of sustainable NRM practices in the past 12 months
    "garden_production", -- Household garden production
    "g74_9", -- G74 What kind of problems have you had in the business
    "g62_total_4", -- Managemant of goats Hoof removal
    "g55_total_1", -- Sustainable NRM practices Agro forester a
    "g76_8", -- G76 Where sold their products in the last 12 months
    "sustainable_ag", -- Number of sustainable agriculture crop practices and or technologies in the past 12 months
    "g79", -- G79 Saved some money in the last 12 months
    "g81_6", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g76_4", -- G76 Where sold their products in the last 12 months
    "g81_9", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g70b", -- G70B In the past year have made calculations of the profits of the business
    "nrm_any", -- Sustainable NRM practices any
    "g81_5", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g76_7", -- G76 Where sold their products in the last 12 months
    "improved_facilities", -- Improved roof wall water and food livestock facilities for rabbits goats pigs poultry
    "g62_total_1", -- Managemant of goats Deworming
    "g74_8", -- G74 What kind of problems have you had in the business
    "improved_beans", -- Use of improved seed for beans
    "g82", -- G82 12 G82 MODULOS COMPLETOS
    "sustainable_crops_any", -- Sustainable crop practices any
    "g81_2", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g76_2", -- G76 Where sold their products in the last 12 months
    "sustainable_crops_cat", -- Farmers who used at least 2 sustainable agriculture crop practices and or technologies in the past 12 months
    "vaccination", -- Vaccination of poultry
    "g72_1", -- G72 What were the organizations that provided loans for business
    "g81_3", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g70_10", -- G70 What type of products sold in the last 12 months
    "value_chain_cat", -- Farmers who practiced the value chain activities promoted by the project in the past 12 months
    "g72_6", -- G72 What were the organizations that provided loans for business
    "g72_2", -- G72 What were the organizations that provided loans for business
    "sustainable_agriculture", -- Number of sustainable agricultural practices and or technologies crop livestock and NRM used in the past twelve months
    "g76_1", -- G76 Where sold their products in the last 12 months
    "sustainable_livestock_cat", -- Farmers who used at least 2 sustainable livestock practices in the past 12 months
    "g72_3", -- G72 What were the organizations that provided loans for business
    "g75", -- G75 Did you have a plan for production and sale in the last 12 months
    "strata", -- Strata
    "fruit_tree_management", -- Fruit tree management practices
    "g74_6", -- G74 What kind of problems have you had in the business
    "g72_8", -- G72 What were the organizations that provided loans for business
    "g62_total_3", -- Managemant of goats Vaccination
    "g72_10", -- G72 What were the organizations that provided loans for business
    "keeping_records", -- Keeping production records
    "g74_5", -- G74 What kind of problems have you had in the business
    "g81_4", -- G81 What where the organizations or savings groups you used in the last 12 months
    "g70c", -- G70C In the past year did you have a notebook where noted these calculations
    "g72_9", -- G72 What were the organizations that provided loans for business
    "g73", -- G73 problems affecting the business in the last 12 months
    "g74_1", -- G74 What kind of problems have you had in the business
    "g77", -- G77 Got agricultural credit in cash or kind in the last 12 months
    "goat_management", -- Number of goat management practices deworming vaccination hoof removal vitamin supplementation
    "g72_5", -- G72 What were the organizations that provided loans for business
    "g74_3", -- G74 What kind of problems have you had in the business
    "g55_total_4", -- Sustainable NRM practices Reforestaci n de fuentes de agua
    "savings", -- Saved money in the last 12 months
    "soil_conservation", -- Use of soil conservation practices
    "fmwt", -- Farmer sampling weight
    "hhwt", -- Household sampling weight
    "cluster", -- Cluster
    "g81_1", -- G81 What where the organizations or savings groups you used in the last 12 months
    "calculation_costs", -- Calculation of cost of production for the market
    "sustainable_nrm_cat", -- Farmers who used at least 2 sustainable NRM practices in the past 12 months
    "g55_total_6" -- Sustainable NRM practices Producci n de plantas forestales
FROM
    "usaid-gov/data-on-agricultural-practices-in-segamil-and-iez5-p5fw:latest"."data_on_agricultural_practices_in_segamil_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 usaid-gov/data-on-agricultural-practices-in-segamil-and-iez5-p5fw 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/data-on-agricultural-practices-in-segamil-and-iez5-p5fw: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/data-on-agricultural-practices-in-segamil-and-iez5-p5fw" \
  --handler-options '{
    "domain": "data.usaid.gov",
    "tables": {
        "data_on_agricultural_practices_in_segamil_and": "iez5-p5fw"
    }
}'

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/data-on-agricultural-practices-in-segamil-and-iez5-p5fw is just another Postgres schema.