delaware-gov/grants-for-weatherization-services-bggt-57c5
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 grants_for_weatherization_services table in this repository, by referencing it like:

"delaware-gov/grants-for-weatherization-services-bggt-57c5:latest"."grants_for_weatherization_services"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "unit_stories", -- Number of stories of the housing unit.
    "other_occupants", -- Number of other persons living in the housing unit.
    "hs_amount_rggi_wap", -- Amount of the total health and safety cost that came from RGGI WAP funds.
    "final_inspector", -- Name of the person who performed the final inspection of the services provided.
    "unit_size", -- Size, in square feet, of the housing unit.
    "zip", -- ZIP Code of the housing unit.
    "children", -- Number of children living in the housing unit.
    "unit_ownership", -- Is the housing unit owned or rented?
    "native_american_occupants", -- Number of Native American persons living in the housing unit.
    "furnace_replacement", -- Was the furnace replaced? (Y or N)
    "hs_amount_liheap", -- Amount of the total health and safety cost that came from LIHEAP funds.
    "hs_amount_wap_utility", -- Amount of the total health and safety cost that came from WAP UTILITY funds.
    "hs_amount_wap_base", -- Amount of the total health and safety cost that came from WAP BASE funds.
    "po_amount_liheap", -- Amount of the total weatherization cost that came from LIHEAP funds.
    "po_amount_wap_utility", -- Amount of the total weatherization cost that came from WAP UTILITY funds.
    "po_amount_rggi_wap", -- Amount of the total weatherization cost that came from RGGI WAP funds.
    "po_amount_wap_base", -- Amount of the total weatherization cost that came from WAP BASE funds.
    "total_invoice_cost", -- Total cost of all weatherization and health and safety services provided to the housing unit. Health and safety costs are those related services not deemed "weatherization" (such as CO and smoke detectors, electrical updates, and ventilation improvements).
    "funding_assignment", -- Funding source, or combination of funding sources, used to pay for weatherization services. They are: WAP BASE (federal Dept. of Energy grant funds for the Weatherization Assistance Program), LIHEAP (federal DHHS grant funds for weatherizing homes), UTILITY (state funds received from Delmarva Power ratepayers designated for weatherizing homes), and RGGI WAP (state funds received through Regional Greenhouse Gas Initiative auctions for weatherization). Prior to 2017, projects for which more than one funding source was used were reported as two records, with identical Client Reference numbers. For details such as numbers of occupants are only reported on the first record.  
    "total_cfm_difference", -- Amount of air leakage, measured in cubic feet per minute, saved through weatherization services.
    "post_wx_test_cfm", -- Amount of air leakage found in tests, in cubic feet per minute, after weatherization services.
    "pre_wx_test_cfm", -- Amount of air leakage found in tests, in cubic feet per minute, before weatherization services.
    "hvac_contractor", -- Name of the HVAC contractor who performed HVAC services.
    "wx_contractor", -- Name of the weatherization contractor who performed the weatherization services.
    "auditor", -- Name of the person who performed the audit of the housing unit.
    "unit_year_built", -- Year that the housing unit was built.
    "utility", -- Utility that provides services to the housing unit.
    "primary_heating_fuel", -- Primary type of fuel used to heat the housing unit.
    "total_occupants", -- Total number of persons living in the housing unit.
    "disabled_occupants", -- Number of disabled persons living in the housing unit.
    "elderly", -- Number of elderly persons living in the housing unit.
    "housing_unit_type", -- Type of housing unit. 
    "county", -- County in which the housing unit is located.
    "city", -- City in which the housing unit is located.
    "program_year", -- Program year in which the final inspection of the services was performed. The program year for this program runs from April 1 to March 31. Program year 2017, for example, ran from April 1, 2017, through March 31, 2018. 
    "client_reference", -- Unique identifier of record of weatherization assistance.
    "invoice_date", -- Date of invoice from agency to DNREC.
    "agency" -- Agency/partner through which the weatherization services were provided. 
FROM
    "delaware-gov/grants-for-weatherization-services-bggt-57c5:latest"."grants_for_weatherization_services"
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 delaware-gov/grants-for-weatherization-services-bggt-57c5 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.delaware.gov. When you querydelaware-gov/grants-for-weatherization-services-bggt-57c5: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.delaware.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 \
  "delaware-gov/grants-for-weatherization-services-bggt-57c5" \
  --handler-options '{
    "domain": "data.delaware.gov",
    "tables": {
        "grants_for_weatherization_services": "bggt-57c5"
    }
}'

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, delaware-gov/grants-for-weatherization-services-bggt-57c5 is just another Postgres schema.