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 hhs_covid19_monthly_outcome_survey_wave_19
table in this repository, by referencing it like:
"healthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83:latest"."hhs_covid19_monthly_outcome_survey_wave_19"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"cam5a_vacclike", -- CAM5a_VaccLike: Vaccine Likelihood
"cam11_par2_grid_6mo4", -- CAM11_Par2_Grid_6mo4: 6 months to 4 years old
"agecat", -- agecat: Age category
"cv4_1_self", -- CV4_1_Self: Self COVID diagnosis
"child_age_1217", -- Child_Age_1217: 12 to 17 years old
"cv10_1_children_home", -- CV10_1_Children_home: kept children home from school
"cam5_vaccdate", -- CAM5_VaccDate: Vaccine Date
"cv11_1_nervous", -- CV11_1_Nervous: Household nervous, anxious, on edge
"bstr1_uptake_2", -- BSTR1_Uptake_2: Booster Uptake
"cv5_4_phone", -- CV5_4_Phone: Consulted with healthcare provider over the phone
"bstr5_par_uptake_1217", -- BSTR5_Par_Uptake_1217: 12 to 17 years old
"bstr2_date", -- BSTR2_Date: Booster Date
"bstr3_like", -- BSTR3_Like: Booster Like
"cv2_3_breath", -- CV2_3_Breath: Shortness of breath
"bstr4_readiness", -- BSTR4_Readiness: Booster Readiness
"cv12_4_little_interest", -- CV12_4_Little_interest: Self little interest or pleasure
"cv9_4_none", -- CV9_4_None: None
"mdate1_req", -- MDATE1_Req: Required
"child_age_04", -- Child_Age_04: 4 years old and younger
"cv2_5_flu", -- CV2_5_Flu: Flu symptoms
"cv5_3_doctor", -- CV5_3_Doctor: Visited doctor's office
"cv3_5_flu", -- CV3_5_Flu: Flu symptoms
"cv3_4_senses", -- CV3_4_Senses: Decreased sense of smell and taste
"child_age_511", -- Child_Age_511: 5 years to 11 years old
"cam11_par1_grid_511", -- CAM11_Par1_Grid_511: 5 to 11 years old
"cv13", -- CV13: Time spent at home
"cv5_7_none", -- CV5_7_None: None of the above
"cam11_par2_grid_511", -- CAM11_Par2_Grid_511: 5 to 11 years old
"cam11_par1_grid_1217", -- CAM11_Par1_Grid_1217: 12 to 17 years old
"cam11_par2_grid_1217", -- CAM11_Par2_Grid_1217: 12 to 17 years old
"cv14_1", -- CV14_1: Kept social distance from others
"cv12_1_nervous", -- CV12_1_Nervous: Self nervous, anxious, on edge
"ppgender", -- ppgender: Gender
"race", -- race: Race
"cv5_6_chat", -- CV5_6_Chat: Consulted with healthcare provider using chat, text, or email
"xurbanicity", -- xurbanicity: Urbanicity
"cv8c", -- CV8c: Current insurance coverage
"cv3_1_fever", -- CV3_1_Fever: Fever
"bstr6_par_read_511", -- BSTR6_Par_Read_511: 5 to 11 years old
"bstr6_par_read_1217", -- BSTR6_Par_Read_1217: 12 to 17 years old
"cv1", -- CV1: Physical health
"cv2_2_cough", -- CV2_2_Cough: Dry cough
"cv2_4_senses", -- CV2_4_Senses: Decreased sense of smell and taste
"cv3_2_cough", -- CV3_2_Cough: Dry cough
"cv3_3_breath", -- CV3_3_Breath: Shortness of breath
"cam6_vaccwait", -- CAM6_VaccWait: Wait to get vaccinated V2
"cv2_1_fever", -- CV2_1_Fever: Fever
"cv4_2_family", -- CV4_2_Family: Family COVID diagnosis
"politicalideo", -- politicalideo: Political ideology
"cv9_1_unemployment_benefits", -- CV9_1_Unemployment_benefits: Unemployment benefits
"cv9_2_covid_enhanced", -- CV9_2_COVID_enhanced: COVID related enhanced unemployment benefits
"cv7b", -- CV7b: Healthcare worker
"public_id", -- public_id: Unique Identifier
"mdate1a_current", -- mdate1a_current: mdate1a_current
"cv8b", -- CV8b: Insurance changed since COVID pandemic
"bstr5_par_uptake_511", -- BSTR5_Par_Uptake_511: 5 to 11 years old
"weights", -- Weights: Weights
"cv10_5_none", -- CV10_5_None: None
"cv11_2_worrying", -- CV11_2_Worrying: Household not able to stop worrying
"cv12_2_worrying", -- CV12_2_Worrying: Self not able to stop worrying
"ppreg4", -- ppreg4: U.S. Census Region 4
"income", -- income: Income
"ppeducat", -- ppeducat: Education -- categorical
"parent", -- parent: Parent
"cv15", -- CV15: Wash hands yesterday
"cv14_5", -- CV14_5: None of the above
"cv14_4", -- CV14_4: Washed or sanitized hands frequently
"cv14_3", -- CV14_3: Avoided enclosed spaces
"cv14_2", -- CV14_2: Wore a mask
"cv12_3_depressed", -- CV12_3_Depressed: Self feeling down, depressed, or hopeless
"cv11_3_depressed", -- CV11_3_Depressed: Household feeling down, depressed, or hopeless
"cv10_4_return_to_work", -- CV10_4_Return_to_work: returned to work after temporary closure
"cv10_3_work_from_home", -- CV10_3_Work_from_home: worked from home more than before the pandemic
"cv10_2_home_schooled", -- CV10_2_Home_schooled: home schooled children
"cam11_par1_grid_6mo4", -- CAM11_Par1_Grid_6mo4: 6 months to 4 years old
"cv11_4_little_interest", -- CV11_4_Little_interest: Household little interest or pleasure
"cv6c_rec", -- CV6c_Rec: Current employment status
"cam5_vaccuptake", -- CAM5_VaccUptake: Vaccine Uptake V2
"cv16", -- CV16: Wash hands time
"cv9_3_cares", -- CV9_3_CARES: CARES Act check
"cv8a", -- CV8a: Insurance coverage prior to COVID pandemic
"cv7a", -- CV7a: Essential worker
"cv6b", -- CV6b: Employment status changed since COVID pandemic
"cv6a_rec", -- CV6a_Rec: Employment status prior to COVID pandemic
"cv5_5_video", -- CV5_5_Video: Consulted with healthcare provider using video chat
"cv5_2_urgent_care", -- CV5_2_Urgent_care: Urgent care facility
"cv5_1_hospital", -- CV5_1_Hospital: Hospital or emergency room
"cv4_3_no" -- CV4_3_No: No COVID diagnosis
FROM
"healthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83:latest"."hhs_covid19_monthly_outcome_survey_wave_19"
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 healthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at healthdata.gov. When you queryhealthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83: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
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 (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 clone
and sgr checkout
.
Mounting Data
This repository is an external repository. It's not hosted by Splitgraph. It is hosted by healthdata.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 \
"healthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83" \
--handler-options '{
"domain": "healthdata.gov",
"tables": {
"hhs_covid19_monthly_outcome_survey_wave_19": "suf4-7q83"
}
}'
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, healthdata-gov/hhs-covid19-monthly-outcome-survey-wave-19-suf4-7q83
is just another Postgres schema.