opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t

  • 2019
  • coronavirus
  • covid
  • covid-19
  • data
  • + 11

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

This repository is an "external" repository. That means it's hosted elsewhere, in this case at opendata.maryland.gov. When you queryopendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t: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 opendata.maryland.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 \
  "opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t" \
  --handler-options '{
    "domain": "opendata.maryland.gov",
    "tables": {
        "md_covid19_master_case_tracker": "mgd3-qk8t"
    }
}'

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, opendata-maryland-gov/md-covid19-master-case-tracker-mgd3-qk8t is just another Postgres schema.

Related Documentation: