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 md_covid19_master_case_tracker
table in this repository, by referencing it like:
"opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t:latest"."md_covid19_master_case_tracker"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"adulticuhospitalizations",
"pdeathnotavail", -- Probable Deaths Data Not Available
"pdeathwhite", -- Probable Deaths White (NH)
"pdeathaframer", -- Probable Deaths African American
"pdeath80plus", -- Probable Deaths for people 80 plus
"pdeath60to69", -- Probable Deaths for people 60 to 69
"pdeath40to49", -- Probable Deaths for people 40 to 49
"pdeath30to39", -- Probable Deaths for people 30 to 39
"pdeathharf", -- Probable Deaths from COVID-19 Harford
"pdeathfred", -- Probable Deaths from COVID-19 Frederick
"pdeathcalv", -- Probable Deaths from COVID-19 Calvert
"pdeathbcity", -- Probable Deaths from COVID-19 Baltimore City
"pdeathanne", -- Probable Deaths from COVID-19 Anne Arundel
"pdeathdod", -- Probable Death Date of Death
"pdeathsdelta", -- Delta of Cumulative Probable Deaths
"pdeaths", -- Cumulative Probable Deaths
"deathother", -- Cumulative Deaths Other (NH)
"deathwhite", -- Cumulative Deaths White (NH)
"deathgenfemale", -- Cumulative Deaths for the Gender Female
"deathgenmale", -- Cumulative Deaths for the Gender Male
"deathageunknown", -- Cumulative deaths for people Age Unknown
"death70to79", -- Cumulative deaths for people 70 to 79
"death60to69", -- Cumulative deaths for people 60 to 69
"death40to49", -- Cumulative deaths for people 40 to 49
"death30to39", -- Cumulative deaths for people 30 to 39
"death20to29", -- Cumulative deaths for people 20 to 29
"death0to9", -- Cumulative deaths for people 0 to 9
"deathunkn", -- Cumulative Deaths from COVID-19 County Unknown
"deathworc", -- Cumulative Deaths from COVID-19 Worcester
"deathwash", -- Cumulative Deaths from COVID-19 Washington
"deathstma", -- Cumulative Deaths from COVID-19 St. Mary's
"deathsome", -- Cumulative Deaths from COVID-19 Somerset
"deathquee", -- Cumulative Deaths from COVID-19 Queen Anne's
"deathmont", -- Cumulative Deaths from COVID-19 Montgomery
"deathkent", -- Cumulative Deaths from COVID-19 Kent
"deathharf", -- Cumulative Deaths from COVID-19 Harford
"deathfred", -- Cumulative Deaths from COVID-19 Frederick
"deathchar", -- Cumulative Deaths from COVID-19 Charles
"deathcarr", -- Cumulative Deaths from COVID-19 Carroll
"deathcaro", -- Cumulative Deaths from COVID-19 Caroline
"deathcalv", -- Cumulative Deaths from COVID-19 Calvert
"deathanne", -- Cumulative Deaths from COVID-19 Anne Arundel
"deathalle", -- Cumulative Deaths from COVID-19 Allegany
"deathdod", -- Death Date of Death
"deathsdelta", -- Delta of Cumulative Statewide Deaths for COVID-19
"casenotavail", -- Cumulative Cases Data not available
"casewhite", -- Cumulative Cases White (NH)
"caseaframer", -- Cumulative Cases African-American
"genfemale", -- Cumulative Cases for the Gender Female
"case70to79", -- Cumulative Cases for people 70 to 79
"case60to69", -- Cumulative Cases for people 60 to 69
"case50to59", -- Cumulative Cases for people 50 to 59
"case40to49", -- Cumulative Cases for people 40 to 49
"case30to39", -- Cumulative Cases for people 30 to 39
"case20to29", -- Cumulative Cases for people 20 to 29
"talb", -- Talbot County Cumulative Cases
"stma", -- St. Mary's County Cumulative Cases
"some", -- Somerset County Cumulative Cases
"quee", -- Queen Anne's County Cumulative Cases
"prin", -- Prince George's County Cumulative Cases
"kent", -- Kent County Cumulative Cases
"fred", -- Frederick County Cumulative Cases
"dorc", -- Dorchester County Cumulative Cases
"ceci", -- Cecil County Cumulative Cases
"carr", -- Carroll County Cumulative Cases
"caro", -- Caroline County Cumulative Cases
"calv", -- Calvert County Cumulative Cases
"balt", -- Baltimore County Cumulative Cases
"anne", -- Anne Arundel County Cumulative Cases
"alle", -- Allegany County Cumulative Cases
"releaseddelta", -- Delta of Cumulative Number of People Released from Isolation
"total_released", -- Cumulative Number of People Released from Isolation
"hospitalizeddelta", -- Delta of Cumulative Number of people Hospitalized
"bedsdelta", -- Delta of Total Number of Hospital Beds
"bedsacute", -- Number of Acute Care Hospital Beds
"bedstotal", -- Total Number of Hospital Beds
"negativetests", -- Cumulative Number of Negative Tests
"totaltests", -- Cumulative Number of COVID-19 Tests
"pdeath20to29", -- Probable Deaths for people 20 to 29
"pdeathunkn", -- Probable Deaths from COVID-19 County Unknown
"pdeathtalb", -- Probable Deaths from COVID-19 Talbot
"pdeathsome", -- Probable Deaths from COVID-19 Somerset
"pdeathquee", -- Probable Deaths from COVID-19 Queen Anne's
"pdeathdorc", -- Probable Deaths from COVID-19 Dorchester
"pdeathbalt", -- Probable Deaths from COVID-19 Baltimore
"deathnotavail", -- Cumulative Deaths Data Not Available
"deathasian", -- Cumulative Deaths Asian (NH)
"deathhispanic", -- Cumulative Deaths Hispanic
"deathgenunkn", -- Cumulative Deaths for the Gender Unknown
"death10to19", -- Cumulative deaths for people 10 to 19
"deathprin", -- Cumulative Deaths from COVID-19 Prince George's
"deathhowa", -- Cumulative Deaths from COVID-19 Howard
"deathceci", -- Cumulative Deaths from COVID-19 Cecil
"deaths", -- Cumulative Statewide Deaths for COVID-19
"caseother", -- Cumulative Cases Other (NH)
"genunkn", -- Cumulative Cases for the Gender Unknown
"genmale", -- Cumulative Cases for the Gender Male
"case10to19", -- Cumulative Cases for people 10 to 19
"wico", -- Wicomico County Cumulative Cases
"casedelta", -- COVID-19 Case Delta
"filter",
"pedacutehospitalizations",
"pdeathwash", -- Probable Deaths from COVID-19 Washingon
"under18",
"unkn", -- Unknown Cumulative Cases
"wash", -- Washington County Cumulative Cases
"pdeathhispanic", -- Probable Deaths Hispanic
"pdeathkent", -- Probable Deaths from COVID-19 Kent
"pdeathcaro", -- Probable Deaths from COVID-19 Caroline
"pdeathalle", -- Probable Deaths from COVID-19 Allegany
"death50to59", -- Cumulative deaths for people 50 to 59
"deathgarr", -- Cumulative Deaths from COVID-19 Garrett
"deathdorc", -- Cumulative Deaths from COVID-19 Dorchester
"deathbalt", -- Cumulative Deaths from COVID-19 Baltimore
"caseageunknown", -- Cumulative Cases Age Unknown
"_65plus",
"pedicuhospitalizations",
"pdeathother", -- Probable Deaths Other (NH)
"pdeathgenfemale", -- Probable Deaths Gender Female
"pdeathageunknown", -- Probable Deaths for people Age Unknown
"pdeath70to79", -- Probable Deaths for people 70 to 79
"pdeath50to59", -- Probable Deaths for people 50 to 59
"pdeath0to9", -- Probable Deaths for people 0 to 9
"pdeathworc", -- Probable Deaths from COVID-19 Worcester
"pdeathprin", -- Probable Deaths from COVID-19 Prince George's
"pdeathmont", -- Probable Deaths from COVID-19 Montgomery
"pdeathhowa", -- Probable Deaths from COVID-19 Howard
"pdeathchar", -- Probable Deaths from COVID-19 Charles
"pdeathceci", -- Probable Deaths from COVID-19 Cecil
"deathaframer", -- Cumulative Deaths African-American
"death80plus", -- Cumulative deaths for people 80 plus
"deathwico", -- Cumulative Deaths from COVID-19 Wicomico
"deathtalb", -- Cumulative Deaths from COVID-19 Talbot
"deathbcity", -- Cumulative Deaths from COVID-19 Baltimore City
"caseasian", -- Cumulative Cases Asian (NH)
"casehispanic", -- Cumulative Cases Hispanic
"case80plus", -- Cumulative Cases for people 80 plus
"case0to9", -- Cumulative Cases for people 0 to 9
"worc", -- Worcester County Cumulative Cases
"mont", -- Montgomery County Cumulative Cases
"howa", -- Howard County Cumulative Cases
"harf", -- Harford County Cumulative Cases
"garr", -- Garrett County Cumulative Cases
"char", -- Charles County Cumulative Cases
"bcity", -- Baltimore City Cumulative Cases
"total_hospitalized", -- Cumulative Number of people Hospitalized
"bedsicu", -- Number of ICU Hospital Beds
"negdelta", -- Delta of Cumulative Number of Negative Tests
"pospercentdiff", -- Delta of 7-Day Rolling Average Positive Testing percent
"postestpercent", -- 7-Day Rolling Average Positive Testing percent
"testsdelta", -- Delta of the Number of COVID-19 Tests
"totalcases", -- Cumulative COVID-19 Cases
"reportdate", -- Report Date
"pdeathasian", -- Probable Deaths Asian (NH)
"pdeath10to19", -- Probable Deaths for people 10 to 19
"adultacutehospitalizations",
"pdeathgenunkn", -- Probable Deaths Gender Unknown
"pdeathgenmale", -- Probable Deaths Gender Male
"pdeathwico", -- Probable Deaths from COVID-19 Wicomico
"pdeathstma", -- Probable Deaths from COVID-19 St. Mary's
"pdeathgarr", -- Probable Deaths from COVID-19 Garrett
"pdeathcarr", -- Probable Deaths from COVID-19 Carroll
"_18to64"
FROM
"opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t:latest"."md_covid19_master_case_tracker"
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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t
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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t: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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t
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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t:latest
This will download all the objects for the latest
tag of opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t
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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t: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 opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t: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, opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t
is just another Postgres schema.