pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz
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 governors_executive_budget_program_measures_sfy table in this repository, by referencing it like:

"pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz:latest"."governors_executive_budget_program_measures_sfy"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "budget_book_budget_year", -- This is the State Fiscal Year when the program measure numbers in this row were submitted for the Governor's Executive Budget Book.
    "subsidy_per_passenger_mile", -- Total subsidy divided by the total number of passenger miles
    "passengers_handled2", -- Total number of trips provided with at least 1-endpoint in Pennsylvania
    "passengers_handled", -- Total number of trips provided by intercity bus carrier
    "surface_repairs", -- The number of miles of seal coating, leveling and sealing, spot patching or other pavement repairs
    "poor_bridges_rehabilitated", -- The number of bridges that were in poor condition but have been rehabilitated or replaced
    "late_bridge_preservations", -- The number of bridges that have had preservation work performed on them late in the timeframe when these activities are appropriate to extend the overall life of the bridge
    "early_bridge_preservations", -- The number of bridges that have had preservation work performed on them early in the timeframe when these activities are appropriate to extend the overall life of the bridge
    "percentage_of_bridges_in_2", -- The percentage of bridges, by count, that are in poor condition based on a single-digit rating that describes the bridge’s overall status in terms of structural soundness and ability to service traveling public.
    "percentage_of_bridges_in_1", -- The percentage of bridges, by count, that are in fair condition based on a single-digit rating that describes the bridge’s overall status in terms of structural soundness and ability to service traveling public.
    "percentage_of_national_highway", -- The percentage of miles on the non-Interstate portion of the National Highway System that are in good condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "fiscal_year", -- This is the fiscal year for which the program measure values in this row are applicable. Fiscal Years 2020-21 and 2021-22 are estimated amounts based on agency projections.
    "percentage_of_service_center", -- Percentage of customers served within 30 minutes at PennDOT’s physical locations.
    "percentage_of_national_highway_2", -- The percentage of miles on the non-Interstate portion of the National Highway System that are in poor condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "percentage_of_national_highway_1", -- The percentage of miles on the non-Interstate portion of the National Highway System that are in fair condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "percentage_of_interstate_2", -- The percentage of miles on the Interstate system that are in poor condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "percentage_of_interstate_1", -- The percentage of miles on the Interstate system that are in fair condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "percentage_of_interstate", -- The percentage of miles on the Interstate system that are in good condition according to the MAP-21 performance measure which is based on surface condition and rideability.
    "percentage_of_bridges_in", -- The percentage of bridges, by count, that are in good condition based on a single-digit rating that describes the bridge’s overall status in terms of structural soundness and ability to service traveling public.
    "number_of_online_egov", -- The number of customers served through PennDOT’s on-line service channel.
    "free_transit", -- Total number of free transit trips provided on fixed route, divided by the amount provided by Lottery funds for Fixed Route Operating Allocation
    "trips_on_state_assisted_shared", -- Total number of trips provided to seniors on shared ride vehicles
    "number_of_free_transit_trips", -- Total number of senior passenger trips provided on fixed route transit in a fiscal year
    "passengers_carried_by_state", -- Total number of passenger trips taken on fixed route in a fiscal year
    "total_miles_of_state", -- The total number of miles of structural restoration, resurfacing, and surface repairs
    "structural_restoration", -- The number of miles of rehabilitation projects with a minimum of 3 inches of new pavement material, as well as associated work such as base repair, drainage, and shoulder
    "miles_of_interstate", -- Miles of Interstate planned to begin construction or reconstruction
    "runways_with_a_pavement", -- % of Runways at 51 airports classified Intermediate, advanced or commercial service which have a Pavement Condition Index value above 60
    "state_assisted_shared_ride", -- Total number of trips provided to seniors on shared ride vehicles divided by the state funding provided for those trips
    "passengers_per_vehicle_hour", -- Total number of passenger trips taken on fixed route, divided by the number of revenue vehicle service hours operated in a fiscal year
    "access_rate_of_driver_and", -- The customers’ access to information through technology and automation, with Customer Service Representatives available to handle complex customer needs, is measured monthly with a minimum requirement of 95.5%.
    "resurfacing", -- The number of miles of new pavement overlays up to 3 inches
    "miles_of_new_highway", -- Miles of new roadway planned to begin construction
    "number_of_closed_bridges", -- The number of bridges that have been closed due to structural inadequacy
    "miles_of_non_interstate", -- Miles of non-interstate highway planned to begin construction or reconstruction.
    "number_of_posted_bridges" -- The number of bridges that have posted weight restrictions
FROM
    "pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz:latest"."governors_executive_budget_program_measures_sfy"
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 pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.pa.gov. When you querypa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz: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.pa.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 \
  "pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz" \
  --handler-options '{
    "domain": "data.pa.gov",
    "tables": {
        "governors_executive_budget_program_measures_sfy": "hxm5-5ddz"
    }
}'

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, pa-gov/governors-executive-budget-program-measures-sfy-hxm5-5ddz is just another Postgres schema.