cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza
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 dohmh_childcare_center_inspections table in this repository, by referencing it like:

"cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza:latest"."dohmh_childcare_center_inspections"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "publichealthhazardviolationrate", -- Percent of Public Health Hazard violations among all violations issued at initial inspections during the past 3 years. If the same violation is cited multiple times during one inspection, it is counted only once.  
    "dc_id", -- Unique DOHMH ID 
    "permitnumber", -- This is the Permit Number of a Child Care or a Camp. This number is not required for a School Based Child Care or After School Program. 
    "maximumcapacity", -- The maximum number of children the facility is allowed, based on the square footage of class and play rooms, the number of toilets and sinks, and overall estimates from the NYC Department of Buildings. Enrollment can be higher than the maximum capacity if there are part-time programs. 
    "childcaretype", -- Group Child Care (GCC) facilities are one of 2 program types: Preschool or Infant/Toddler. All GCC citywide statistics are calculated by type. 
    "bin", -- Building Identification Number assigned by the NYC  Department of Buildings to the building where the facility is located. If the last 6 digits are '0' then the address was not geocoded and the first digit designates the borough. 
    "violationcategory", -- Violation Category - Public Health Hazard (violation needs to be fixed within 1 day),  Critical (Violation needs to be fixed within 2 weeks), General (Violation needs to be fixed in 30 days) or null/blank for no violation in the inspection 
    "agerange", -- This field represents the possible age range of children in the program. 
    "zipcode", -- Zip code as per the address of the entity 
    "criticalviolationrate", -- Percent of Critical violations among all violations issued at initial inspections during the past 3 years. If the same violation is cited multiple times during one inspection, it is counted only once.  
    "averagepublichealthhazardiolationrate", -- Citywide average number of PHH (Public Health Hazard) violation categories over 3 years for a Child Care Type.  
    "datepermitted", -- Estimated date that the site was orignally permitted, used to calculate the age of the program. See Actual field for additional information. 
    "facilitytype", -- Facility Type: FDC  - Family Day Care (State licensed),  GFDC - Group Family Day Care (State Licensed), SBCC - School Base Child Care (Licensed by NYS, DOE, Charter School or Regents), Camp, SMPG - Summer Program (NYS or NYC licensed), GDC - Group Day Care (NYC DOHMH Permitted), SACC - School Age Child Care (After School - State Licesned) 
    "avgcriticalviolationrate", -- Citywide average number of Critical violation categories over 3 years for a Child Care Type.  
    "status", -- SBCC: 'Active''; GDC & Camp: 'Permitted', 'Expired-In Renewal', 'Permit Suspended'; SMPG: 'Registered'. There are other statuses, such as Pending (prior to operational status) and OOB (Out of Business), but data are available only for currently operating child care facilities. 
    "borough", -- Borough as per the address of the entity 
    "actual", -- Flag for correct (actual) date of original permit. Some programs pre-date the current DOHMH systems and do not have record of their original permit date. 'Y' indicates that the actual date is available, while 'N' indicates that the program was originally permitted sometime before the DatePermitted. 
    "inspectionsummaryresult", -- The summary result of the inspection, based on the type of inspection and the number and types of violations. 
    "violationratepercent", -- Percent of Initial Inspections that resulted in at least one Critical or Public Health Hazard (PHH) violation 
    "centername", -- This is the Legal name of the Entity that permits the Child Care Center  
    "programtype", -- Program Type - Infant Toddler, Preschool, After School, Preschool Camp, School Age Camp, All Age Camp 
    "violationstatus", -- Violation Status - Open, Corrected or N/A. 
    "building", -- Building portion of the address. 
    "permitexp", -- This field represents the date a permit expired. All Group Child Care Centers (GDC) are permitted for 2 years and Camps for one. (All camps expire automatically on Sept. 15 of the year they opened). 
    "violationavgratepercent", -- Citywide average violation rate calculated as percent of Initial Inspections that ended with a Critical or PHH (Public Health Hazrd) violation for a specific Child Care Type. Compare with Violation Rate to see if above or below it peers for a Child Care Type 
    "healthcodesubsection", -- Health Code Sub Section 
    "phone", -- Phone Number 
    "regulationsummary", -- Violation Description Language or null/blank for no violation in the inspection 
    "averagetotaleducationalworkers", -- Citywide average total number of Educational Staff in the program - includes teachers, assistant teachers and non administrative directors for a Child Care Type 
    "street", -- Street portion of the address. 
    "url", -- Website for the child care center.  
    "totaleducationalworkers", -- Current number of Educational Staff in the program, including teachers, assistant teachers, teacher directors and education directors. Note that staff data are updated only upon inspection and may be outdated. 
    "inspectiondate", -- Inspection Date 
    "legalname" -- This is the name of the Child Care Center as known to the public (DBA) 
FROM
    "cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza:latest"."dohmh_childcare_center_inspections"
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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza 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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza: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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza

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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza:latest

This will download all the objects for the latest tag of cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza 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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza: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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza: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, cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza is just another Postgres schema.

Related Documentation:

Loading...