cityofnewyork-us/2018-prek-school-directory-xck4-5xd5
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 procotol. 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 2018_prek_school_directory table in this repository, by referencing it like:

"cityofnewyork-us/2018-prek-school-directory-xck4-5xd5:latest"."2018_prek_school_directory"

or in a full query, like:

SELECT 
    ":id", -- Socrata column ID
    "nyceec_siblings_some", -- For NYCEECs: designates whether some current students received offers last year
    "hours", -- Program hours
    "accessibility", -- Designates the program's level of accessibility. 
    "lpga", -- A note explaining who received offers last year for programs with unique priority structures or for those in choice districts. Programs new to the 2018 Pre-K Application are also noted here. 
    "pkc_outdistrict_all", -- For  District programs: designates whether all out-of-district students received offers last year
    "rezoning", -- Designates district schools that could potentially be impacted by a rezoning proposal. 
    "district_outdistrict_1", -- For  District programs: designates whether some in-district students received offers last year
    "district_outdissibs", -- For  District programs: designates whether all out-of-district siblings  received offers last year
    "district_indistrict", -- For  District programs: designates whether all in-district students received offers last year
    "bin", -- The BIN (Building Identification Number) is a unique identifier for each building in the City. 
    "district_zonedsib_2", -- For  District programs: designates whether no zoned students received offers last year
    "district_otherzone", -- For  District programs: designates whether all in-district siblings  received offers last year
    "district_2", -- For  District programs: designates whether some in-district siblings  received offers last year
    "subway_stop", -- Subway lines near the school
    "programcode3", -- Code families use on the application to apply to that specific program (affiliated with programname3). 
    "district_outdistrict", -- For  District programs: designates whether all in-district students received offers last year
    "district_indistrict_2", -- For  District programs: designates whether no out-of-district siblings  received offers last year
    "enhancedlang_note", -- Designates whether a program is an Enhanced Language program.  Identifies the target language. 
    "iepnote", -- A note that prompts families of students with particular IEP recommendations to contact the program. 
    "diversity", -- Designates whether a program is part of the Diversity in Admissions pilot. 
    "district_3", -- For  District programs: designates whether no in-district siblings  received offers last year
    "district_outdissibs_2", -- For  District programs: designates whether no out-of-district siblings  received offers last year
    "magnet", -- Designates whether a program is a magent program. Describes the curricular focus of that magent program. 
    "district_indistrict_1", -- For  District programs: designates whether some in-district students received offers last year
    "district_outdissibs_1", -- For  District programs: designates whether some out-of-district siblings  received offers last year
    "community_board", -- The Community Board field indicates the New York City Community District where the building is located. 
    "latitude", -- Latitude of the building's location. 
    "seats", -- The number of full-day, half-day and 5 hour seats at program(s) last year. 
    "singlegender", -- Flag for programs that may have some single-gender classrooms or are single-gender programs   
    "pkc_outdistrict_some", -- For  District programs: designates whether some out-of-district students received offers last year
    "prek_type", -- Pre-K program type
    "contact_name", -- The name of the contact person at the school
    "census_tract", -- The Census Tract field indicates the U.S. Census Tract where the building is located. 
    "specialpriority", -- Describes the priority structures for programs with unique admissions priorities.  This also flags programs located in choice districts.
    "earlydropoff", -- Time a program starts early dropoff. 
    "district_outdistrict_2", -- For  District programs: designates whether no in-district students received offers last year
    "pkc_indistrict_all", -- For  District programs: designates whether all in-district students received offers last year
    "pkc_indistrict_none", -- For  District programs: designates whether no in-district students received offers last year
    "bbl", -- The BBL (Borough, Block, and Lot) is a unique identifier for each tax lot in the City. 
    "postcode", -- Zipcode where the building is located
    "programname3", -- Designates whether the third program at the school (if applicable) is full-day, half-day, 5 hour, or dual language. 
    "phone", -- School's phone number 
    "play", -- Designates the type of playspace a school has available to students and whether the space is indoor, outdoor, onsite or offsite
    "locationname", -- School's name
    "district", -- Community School District school is located 
    "latepickup", -- Time a program ends late pickup.  
    "flexschedule", -- Designates whether a program may have a flexible scheduling policy.
    "nyceec_targetlang_2", -- For  NYCEECs and are Enhanced Language programs: designates whether no students that speak the target language received offers last year
    "council_district", -- The Council District field indicates the New York City Council District where the building is located. 
    "nyceec_current_all", -- For NYCEECs: designates whether all current students received offers last year.
    "nyceec_siblings_all", -- For  NYCEECs: designates whether all siblings received offers last year
    "meals", -- Designates which meals are provided to students during the school day.  Values can be all, none or some of the following: breakfast, lunch, snack(s)
    "nyceec_services_none", -- For  NYCEECs: designates whether no students receiving social services received offers last year
    "district_zonedsib", -- For  District programs: designates whether all zoned siblings received offers last year
    "nyceec_current_some", -- For NYCEECs: designates whether some current students received offers last year
    "nyceec_services_some", -- For  NYCEECs: designates whether some students receiving social services received offers last year
    "schooldbn", -- DBN (District Borough Number): code used by the NYC Department of Education to uniquely identify schools
    "final_address", -- School's address
    "uniforms", -- Flag for programs that have a uniform requirement
    "programcode2", -- Code families use on the application to apply to that specific program (affiliated with programname2). 
    "contact_email", -- The email of the contact person at the school
    "website", -- School website
    "nyceec_others_all", -- For  NYCEECs: designates whether all other students received offers last year
    "district_otherzone_1", -- For  District programs: designates whether some in-district siblings  received offers last year
    "nta", -- The Neighborhood Tabulation Area field indicates the New York City Neighborhood area where the building is located.
    "district_zonedsib_1", -- For  District programs: designates whether some zoned siblings received offers last year
    "nyceec_others_some", -- For  NYCEECs: designates whether some other students received offers last year
    "nyceec_others_none", -- For  NYCEECs: designates whether no other students received offers last year
    "bus", -- Bus lines near the school
    "halfday_offers", -- A note explaining that the "Who Got Offers" chart does not apply to half-day programs. 
    "district_1", -- For  District programs: designates whether all in-district siblings  received offers last year
    "district_otherzone_2", -- For  District programs: designates whether some zoned students received offers last year
    "nyceec_current_none", -- For  NYCEECs: designates whether no current students received offers last year
    "pkc_outdistrict_none", -- For  District programs: designates whether no out-of-district students received offers last year
    "pkc_indistrict_some", -- For  District programs: designates whether some in-district students received offers last year
    "borough", -- Borough where school is located
    "nyceec_siblings_none", -- For  NYCEECs: designates whether no siblings received offers last year
    "nyceec_services_all", -- For  NYCEECs: designates whether all students receiving social services received offers last year
    "nyceec_targetlang_1", -- For  NYCEECs and are Enhanced Language programs: designates whether some students that speak the target language received offers last year
    "nyceec_targetlang", -- For  NYCEECs and are Enhanced Language programs: designates whether all students that speak the target language received offers last year
    "income_flg", -- Flag for programs that may have income or other eligibility requirements.  
    "programcode1", -- Code families use on the application to apply to that specific program (affiliated with programname1). 
    "programname2", -- Designates whether the second program at the school (if applicable) is full-day, half-day, 5 hour, or dual language. 
    "programname1", -- Designates whether the first program offered at the school is full-day, half-day, 5 hour, or dual language. 
    "longitude" -- Longitude of the building's location.  
FROM
    "cityofnewyork-us/2018-prek-school-directory-xck4-5xd5:latest"."2018_prek_school_directory"
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/2018-prek-school-directory-xck4-5xd5 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cityofnewyork.us. When you querycityofnewyork-us/2018-prek-school-directory-xck4-5xd5: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)"
 

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.cityofnewyork.us, 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 \
  "cityofnewyork-us/2018-prek-school-directory-xck4-5xd5" \
  --handler-options '{
    "domain": "data.cityofnewyork.us",
    "tables": {
        "2018_prek_school_directory": "xck4-5xd5"
    }
}'

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, cityofnewyork-us/2018-prek-school-directory-xck4-5xd5 is just another Postgres schema.

Related Documentation: