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 governors_executive_budget_program_measures_sfy
table in this repository, by referencing it like:
"pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx:latest"."governors_executive_budget_program_measures_sfy"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"rate_of_maternal_mortality", -- This rate is measuring the pregnancy-related deaths (death while pregnant or within 1 year of its end, regardless of outcome, duration or site of pregnancy–from any cause related to or aggravated by pregnancy or its management; not from accidental/incidental causes) and the disparity is calculated by subtracting the rates for Black and White maternal deaths to identify the value between each data point. Data comes from the National Vital Statistics System and the Pregnancy Mortality Surveillance System from the Centers for Disease Control and Prevention, which utilizes Department of Health death certificates for all women who died during pregnancy or within 1 year of pregnancy and links to live births or fetal death certificates.
"number_of_newly_hiv_diagnose", -- The Centers for Disease Control and Prevention defines linkage to care measure as the percentage of people receiving a diagnosis of HIV in a given calendar year who had one or more documented CD4 or viral load tests within 30 days (one month) of diagnosis. For this measure, the denominator is persons receiving a diagnosis of HIV in a measurement year and the numerator is the number of persons who were linked to care within 30 days (one month).
"percentage_of_completion", -- For immigrants and refugees with abnormal chest x-rays read overseas as consistent with TB who are diagnosed with LTBI or have radiographic findings consistent with prior pulmonary TB on the basis of examination in the U.S., and who have started on treatment, increase the proportion who complete treatment.
"percentage_of_inititation", -- For immigrants and refugees with abnormal chest x-rays read overseas as consistent with TB who are diagnosed with LTBI or have radiographic findings consistent with prior pulmonary TB on the basis of examination in the U.S., for whom treatment was recommended, increase the proprortion who start treatment.
"number_of_cases_of_chlamydia", -- This measure reflects the total number of reported cases of chlamydia per 100,000 individuals in PA NEDSS.
"percentage_children_72_months", -- The percentage of children tested under age 6 with a confirmed elevated blood lead level (EBLL) greater than or equal to 5 μg/dL, defined by the Centers for Disease Control and Prevention as a venous BLL greater than or equal to 5 μg/dL, or two capillary BLLs greater than or equal to 5 μg/dL within 84 days of each other is being measured.
"percentage_of_obese_adults", -- The percentage of adults with obesity (Body Mass Index >30) in Pennsylvania is being measured.
"percentage_of_school_districts", -- The percentage of schools that are at or above the 1500:1 ratio of students to school nurses required by Pennsylvania law is being measured.
"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_teens_who_vape", -- The percentage of teenagers who are current users of electronic cigarettes is being measured.
"percentage_of_children_72", -- The percentage of children under age 6 who receive at least one blood lead level (BLL) screening (venous or capillary) during the calendar year is being measured
"percentage_of_adults_age_1", -- The percentage of adults who are current users of electronic cigarettes in Pennsylvania is being measured.
"percentage_of_adults_age", -- The percentage of adults who are current smokers in Pennsylvania is being measured.
"percentage_completion_of", -- For patients with newly diagnosed TB disease for whom 12 months or less of treatment is indicated, increase the proportion who complete treatment within 12 months.
"event_date_lag_for_death", -- The lag time is being measured for each death record based on the date of death and the date of data transmittal to the CDC-National Center for Health Statistics (NCHS). Note: the higher rate equals better performance.
"calculated_lag_for_birth", -- The calculated lag time is measured for each record (birth and death) based on the date of registration with the Department’s Vital Events Registry as compared to the date of data transmittal to the CDC-National Center for Health Statistics (NCHS). Note: the higher rate equals better performance.
"neonatal_abstinence_syndrome", -- The number of neonatal abstinence syndrome (NAS) cases reported to the state by birthing facilities and pediatric hospitals are newborns born to Pennsylvania residents or residing in state after birth that exhibiting symptoms of withdrawal due to prenatal opioid, barbiturate, or benzodiazepine exposure. Prior to 2020, the definition for cases did not include benzodiazepines or barbiturates.
"number_of_cases_of_primary", -- This measure reflects the total number of reported cases of Primary and Secondary (P&S) Syphilis per 100,000 individuals in PA NEDSS.
"percentage_of_teens_who_smoke", -- The percentage of teenagers who are current smokers in Pennsylvania is being measured.
"rate_of_the_mortality", -- This rate is measuring the death of a child ages 1-4 years old. The disparity is calculated by subtracting the rates for Black and White children aged 1-4 years to identify the value between each data point. Data comes from the National Vital Statistics System.
"percentage_inititation_of", -- For TB patients with positive acidfast bacillus (AFB) sputum-smear results, increase the proportion who initiated treatment within 7 days of specimen collection.
"percentage_kindergarten", -- The rate of kindergarten students vaccinated against MMR is being measured.
"percentage_adults_with", -- The percentage of adults with diabetes in Pennsylvania is being measured.
"number_of_drug_related", -- Drug overdose deaths include overdoses from illicit, prescription or over-the-counter drugs, excluding alcohol-only related overdoses, where the manner of death was “Accidental” or “Undetermined.” Counts/rates do not include “Homicides” or “Suicides.”
"event_date_lag_for_birth", -- The lag time is being measured for each birth record based on the date of birth and the date of data transmittal to the CDC-National Center for Health Statistics (NCHS). Note: the higher rate equals better performance.
"rate_of_mortality_disparity", -- This rate is measuring the death of a child within the first year of life and the disparity is calculated by subtracting the rates for Black and White children to identify the value between each data point. Data comes from the National Vital Statistics System.
"number_of_individuals_who", -- The number of individuals who tested HIV negative at publicly funded testing locations and were referred to pre-exposure prophylaxis (PrEP) services measurement is determined by data from EvaluationWeb, a Centers for Disease Control and Prevention sponsored database and the Centers for Disease Detection laboratory data entry system.
"number_of_cases_of_gonorrhea", -- This measure reflects the total number of reported cases of gonorrhea per 100,000 individuals in PA NEDSS.
"year_budget_finalized" -- This is the State Fiscal Year when the program measure numbers in this row were submitted for the Governor's Executive Budget Book.
FROM
"pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx: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-pqba-6idx
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 pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx: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 pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx
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 pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx:latest
This will download all the objects for the latest
tag of pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx
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 pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx: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 pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx: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, pa-gov/governors-executive-budget-program-measures-sfy-pqba-6idx
is just another Postgres schema.