Query the Data Delivery Network
Query the DDNThe 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-4r7n-43gt:latest"."colorado_licensed_child_care_facilities_report"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"cccap_total_auth_d2", -- the total number of CCCAP authorizations for all fiscal agreements [reflects most current data available; through the previous two weeks prior from the date of this report or D2]
"cccap_fa_exp_date_d2", -- the latest CCCAP fiscal agreement expiration date across any associated county [reflects most current data available; through the previous two weeks prior from the date of this report or D2]
"cccap_amount_paid_d1", -- CCCAP subsidy dollars paid out for care occurring in the month; Parent fee (copay) is not included in this amount [reflects most current data available; two months prior to the date of this report or D1]
"cccap_fa_status_d1", -- the status of the CCCAP fiscal agreement with at least one county, with '1' indicating 'open' status [reflects data two months prior to the date of this report or D1]
"cccap_fa_exp_date_d1", -- CCCAP fiscal agreement expiration date across any associated county [reflects data two months prior to the date of this report or D1]
"total_licensed_capacity", -- the maximum number of children for whom care can be provided at any point in time
"award_date", -- award/assign date of QRIS RATING LEVEL
"school_district", -- the name of the school district the provider is located in
"ccrr", -- the name of the Child Care Resource and Referral organization the provider is associated with
"community", -- the name of the Census county subdivision
"zip", -- physical location ZIP postal code as it appears in the licensing application
"provider_service_type", -- license type based on type of service; values include ‘Child Care Center’, ‘Preschool Program’, ‘Family Child Care Home’, ‘Three Under Two Child Care Home’, ‘Experienced Family Child Care Home’, ‘Infant/Toddler Home’, ‘Large Family Child Care Home’, 'Neighborhood Youth Organization', 'Resident Camp', and 'School Age Child Care Center'; does not include 24-hour license types (e.g., day treatment) or license-exempt child care
"provider_id", -- unique CDHS-issued license number
"report_date", -- report date of system record and attributes
"geocoded_column_zip",
"geocoded_column",
"cccap_fa_status_d2", -- the status of the CCCAP fiscal agreement with at least one county, with '1' indicating 'open' status [reflects most current data available; through the previous two weeks prior from the date of this report or D2]
"expiration_date", -- expiration date of QRIS RATING LEVEL
"county", -- the name of the county for each program’s location as it appears in the licensing application
"state", -- physical location state name as it appears in the licensing application
"primary_key", -- unique system record identification key
"geocoded_column_address",
":@computed_region_nku6_53ud", -- This column was automatically created in order to record in what polygon from the dataset 'Counties' (nku6-53ud) the point in column 'geocoded_column' is located. This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
"geocoded_column_state",
"geocoded_column_city",
"cccap_total_auth_d1", -- the total number of CCCAP authorizations for all fiscal agreements [reflects data two months prior to the date of this report or D1]
"cccap_case_count_d1", -- the number of cases (or families) with at lease one child utilizing CCCAP at least once during the month [reflects most current data available; two months prior to the date of this report or D1]
"ecc", -- the name of the Early Childhood Council the provider is associated with
"provider_name", -- legal business name as it appears in the licensing application
"street_address", -- full physical location street address as it appears in the licensing application
"city", -- physical location city name as it appears in the licensing application
"cccap_child_count_d1", -- the number of children utilizing CCCAP at least once during the month [reflects most current data available; two months prior to the date of this report or D1]
"qris_rating_level" -- 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
FROM
"colorado-gov/colorado-licensed-child-care-facilities-report-4r7n-43gt: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-4r7n-43gt
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because colorado-gov/colorado-licensed-child-care-facilities-report-4r7n-43gt: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-4r7n-43gt
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-4r7n-43gt:latest
This will download all the objects for the latest
tag of colorado-gov/colorado-licensed-child-care-facilities-report-4r7n-43gt
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-4r7n-43gt: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-4r7n-43gt: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-4r7n-43gt
is just another Postgres schema.