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

"colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu:latest"."colorado_licensed_child_care_facilities_report"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "governing_body", -- “Governing Body” means the individual, partnership, corporation, or association in which the ultimate authority and legal responsibility is vested for the administration and operation of a child care facility.
    "licensed_resident_camp_capacity", -- The maximum number of children who have completed kindergarten or are six years of age or older for whom care can be provided at any point in time for licensed Resident Camps. NOTE: These programs are often seasonal and providers included in this dataset may have an open license but may not be in operation at the time of the pull. 
    "licensed_preschool_and_school_age_capacity", -- The maximum number of children ages 2 years and older for whom care can be provided at any point in time
    "licensed_school_age_capacity", -- The maximum number of children ages 5 years and older for whom care can be provided at any point in time
    "licensed_toddler_capacity", -- The maximum number of children ages 12 months - 36 months for whom care can be provided at any point in time
    "licensed_infant_capacity", -- The maximum number of children ages 6 weeks - 18 months for whom care can be provided at any point in time
    "licensed_home_capacity", -- The maximum number of children cared for in a child care home setting (Family Child Care Home, Family Child Care Home 3, Experienced Child Care Provider, Infant and Toddler Home, and Large Child Care Home) for whom care can be provided at any point in time. Due to licensing processes, this field is populated for home providers only. Ages authorized vary by home provider license type. For more information on a specific provider, please refer to the rules and regulations governing their license type.
    "cccap_fa_status_d1", -- A Fiscal Agreement is a state-approved agreement between counties or their designees and child care provider(s) and must be in place in order for a child care provider to accept and be reimbursed for providing care to a child engaged in CCCAP. A Fiscal Agreement means a provider has the ability to be reimbursed through CCCAP but it is not an indication that the provider is currently providing care for children in CCCAP.   For CIM: A true value indicates there is an active fiscal agreement on file at the date of the pull.
    "total_licensed_capacity", -- The maximum number of children for whom care can be provided at any point in time
    "expiration_date", -- Expiration date of QUALITY RATING LEVEL; if rating level is greater than 1 and Quality Rating Effective Date is blank, this indicates that the program obtained that rating through an alternative pathway
    "award_date", -- Award/assign date of QUALITY RATING LEVEL; if rating level is greater than 1 and Quality Rating Effective Date is blank, this indicates that the program obtained that rating through an alternative pathway
    "quality_rating", -- final quality rating level as determined by the highest valid rating available; if blank, the program is not QRIS-eligible, and ratings are not applicable
    "school_district", -- The name of the school district the provider is located in. NOTE: This field is not required and is self-reported via picklist options – it is subject to errors and underreporting. If a School District is populated in this field, it does not indicate an association with the School District itself.
    "school_district_operated_program", -- An indication of whether a provider is operated by a School District, with ‘TRUE’ indicating that the provider is operated by a School District. NOTE: This is a newly required field and does not necessarily reflect all School District Operated programs. 
    "ccrr", -- The name of the Child Care Resource and Referral organization the provider is associated with 
    "ecc", -- The name of the Early Childhood Council the provider is associated with
    "county", -- The name of the county for each program’s location as it appears in the licensing application
    "zip", -- Physical location ZIP postal code as it appears in the licensing application
    "city", -- Physical location city name as it appears in the licensing application
    "street_address", -- Full physical location street address as it appears in the licensing application
    "provider_service_type", -- License type based on type of service; values include ‘Child Care Center’, ‘Preschool’, ‘Family Child Care Home’, ‘Family Child Care Home 3, ‘Experienced Child Care Provider’, ‘Infant /toddler home’, ‘Large child care home’, 'Neighborhood Youth Organization', 'Resident Camp', and 'School age child care'; does not include 24-hour license types (e.g., day treatment) or license-exempt child care.
    "provider_name", -- Legal business name as it appears in the licensing application
    "provider_id", -- Unique CDEC-issued license number
    "licensed_nyo_capacity", -- The maximum number of children ages 5 years and older for whom care can be provided at any point in time for licensed Neighborhood Youth Organizations.
    "licensed_preschool_capacity", -- The maximum number of children ages 2.5 years -  7 years for whom care can be provided at any point in time
    "cccap_authorization_status", -- An Authorization outlines the amount and length of time a child who has applied is eligible to receive care by licensed or qualified exempt providers for which a CCCAP payment will be made. Authorizations are not an indication of the amount of care the family or child utilizes, rather it is the maximum amount and length approved.  For CIM: A true value indicates there is an active authorization on file at the date of the pull.
    "state" -- Physical location state name as it appears in the licensing application
FROM
    "colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu:latest"."colorado_licensed_child_care_facilities_report"
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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu 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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu: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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu

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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu:latest

This will download all the objects for the latest tag of colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu 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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu: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 colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu: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, colorado-gov/colorado-licensed-child-care-facilities-report-a9rr-k8mu is just another Postgres schema.

Related Documentation:

Loading...