ct-gov/covid19-state-level-data-archive-qmgw-5kp6
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 covid19_state_level_data_archive table in this repository, by referencing it like:

"ct-gov/covid19-state-level-data-archive-qmgw-5kp6:latest"."covid19_state_level_data_archive"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "cumulative_deaths_hisp_race_5", -- Deaths by ethnicity Non-Hispanic White cumulative
    "cumulative_deaths_hisp_race_4", -- Deaths by ethnicity Non-Hispanic Multiracial cumulative
    "cumulative_deaths_hisp_race_3", -- Deaths by ethnicity Non-Hispanic Black cumulative
    "cumulative_deaths_agegroup_7", -- Deaths in age group 70 - 79 cumulative
    "cumulative_cases_gender_na", -- Cases by gender Not Applicable cumulative
    "cumulative_cases_gender_other", -- Cases by gender Other cumulative
    "cumulative_cases_hisp_race_6", -- Case by ethnicity Unknown cumulative
    "cumulative_cases_hisp_race_5", -- Case by ethnicity Non Hispanic White cumulative
    "cumulative_cases_hisp_race_4", -- Case by ethnicity Non Hispanic Multiracial cumulative
    "cumulative_cases_hisp_race_1", -- Case by ethnicity Non Hispanic Amnerican Indian or Alaskan Native cumulative
    "cases_hisp_race_unknown_7days", -- Case by ethnicity Unknown in the past 7 days
    "cases_hisp_race_nh_multiracial", -- Case by ethnicity Non Hispanic Multiracial in the past 7 days 
    "cases_hisp_race_nh_asian_or_pacific", -- Case by ethnicity Non Hispanic Asian or Pacific Islander in the past 7 days
    "cases_age_group_80_7days", -- Cases by age group >= 80 in the past 7 days
    "cases_age_group_10_19_7days", -- Cases by age group 10 - 19 in the past 7 days
    "census_7days_ago", -- CHA reported hospital census 7 days ago
    "nonvax_today", -- Number of CHA reported COVID-19 Hospitalized patients that are not vaccinated
    "partialvax_today", -- Number of CHA reported COVID-19 Hospitalized patients that are partially vaccinated
    "fullyvax_today", -- Number of CHA reported COVID-19 Hospitalized patients that are fully vaccinated
    "cumulative_tests_naat", -- Number of all PCR/NAAT tests since the start of the pandemic
    "probable_cases_7days", -- Total number of probable cases reported in the past 7 days
    "cumulative_deaths_hisp_race_6", -- Deaths by ethnicity race unknown cumulative
    "cumulative_cases_hisp_race", -- Case by ethnicity Hispanic cumulative
    "cumulative_cases_agegroup", -- Cases by age group 0 - 9 cumulative
    "cases_age_group_20_29_7days", -- Cases by age group 20 -29 in the past 7 days
    "report_date", -- The date this report was issued/published
    "data_updated", -- Date the data were updated
    "cumulative_cases_gender", -- Cases by gender Unknown cumulative 
    "cumulative_cases_hisp_race_2", -- Case by ethnicity Non Hispanic Asian or Pacific Islander cumulative
    "cases_hisp_race_nh_white_7days", -- Case by ethnicity Non Hispanic White in the past 7 days
    "cumulative_cases_agegroup_6", -- Cases by age group 60 - 69 cumulative
    "cumulative_cases_agegroup_5", -- Cases by age group 50 - 59 cumulative
    "cumulative_cases_agegroup_2", -- Cases by age group 20 - 29 cumulative
    "cases_age_group_50_59_7days", -- Cases by age group 50 - 59 in the past 7 days
    "census_pct_not_fully_vax", -- Percent of CHA reported hospital census not fully vaccinated (Partial + Non / Census)
    "census_change", -- Change in hospital census since 7 days
    "census_today", -- CHA reported COVID-19 Hospital Census
    "newly_reported_deaths", -- Number of newly reported deaths since the last Thursday Report 
    "cases_7days", -- Total number of cases reported in the past 7 days
    "cumulative_cases_probable", -- Total number of probable cases from the start of the pandemic 
    "cumulative_cases_confirmed", -- Total number of confirmed cases from the start of the pandemic
    "cumulative_deaths_agegroup_6", -- Deaths in age group 60 - 69 cumulative
    "case_rate_weekly", -- Case Rate per 100,00 (cases in the last 7 days / population) * 100,000  [State and County Population is based on 2020 estimates.   Town Population is based on 2019 estimates]
    "positive_ag_7days", -- Number of Positive AG tests in the past 7 days
    "tests_reportable_7days", -- Number of all PCR test + positive AG tests in the last 7 days
    "cumulative_deaths_gender_1", -- Cumulative male deaths
    "cumulative_cases_gender_male", -- Cases by gender Male cumulative
    "cases_age_group_0_9_7days", -- Cases by age group 0 -9 in the past 7 days
    "cumulative_deaths", -- Total number of deaths from the start of the pandemic
    "cumulative_deaths_gender_3", -- Cumulative gender unknown deaths
    "cumulative_deaths_hisp_race", -- Deaths by ethnicity Hispanic cumulative
    "cumulative_deaths_agegroup_8", -- Deaths in age group >=80 cumulative
    "cumulative_cases_gender_female", -- Cases by gender Female cumulative
    "cumulative_cases_agegroup_8", -- Cases by age group >= 80 cumulative
    "cases_age_group_70_79_7days", -- Cases by age group 70 - 79 in the past 7 days
    "cases_age_group_60_69_7days", -- Cases by age group 60 - 69 in the past 7 days
    "tests_naat_7days", -- Number of all PCR/NAAT tests in the past 7 days
    "cumulative_cases_agegroup_7", -- Cases by age group 70 - 79 cumulative
    "cumulative_deaths_agegroup_5", -- Deaths in age group 50 - 59 cumulative
    "cases_gender_male_7days", -- Cases by gender Male in the past 7 days
    "cases_hisp_race_hispanic_7days", -- Case by ethnicity Hispanic in the past 7 days
    "cases_age_group_40_49_7days", -- Cases by age group 40 - 49 in the past 7 days
    "adddose_today", -- Number of CHA reported patients that have an additional dose of vaccine beyond "fully vaccinated"
    "positive_naat_7days", -- Number of Positive PCR/NAAT tests in the past 7 days
    "cumulative_cases_agegroup_1", -- Cases by age group 10 - 19 cumulative
    "cumulative_positive_naat", -- Number of Positive PCR/NAAT tests since the start of the pandemic
    "cumulative_deaths_agegroup_4", -- Deaths in age group 40 - 49 cumulative
    "cumulative_cases_agegroup_4", -- Cases by age group 40 - 49 cumulative
    "naat_positivity_7days", -- Percent Positivity  (Positive PCR/NAAT divided by All PCR/NAAT in the past 7 days)
    "cumulative_deaths_agegroup_3", -- Deaths in age group 30 - 39 cumulative
    "cumulative_deaths_agegroup_1", -- Deaths in age group 10- 19 cumulative
    "cases_gender_unknown_7days", -- Cases by gender Unknown in the past 7 days
    "cumulative_cases_agegroup_9", -- Cases by age group not available cumulative
    "cases_age_group_30_39_7days", -- Cases by age group 30 - 39 in the past 7 days
    "cases_hisp_race_nh_american_indian", -- Case by ethnicity Non Hispanic Amnerican Indian or Alaskan Native in the past 7 days
    "confirmed_cases_7days", -- Total number of confirmed cases reported in the past 7 days
    "cases_gender_female_7days", -- Cases by gender Female in the past 7 days
    "cases_hisp_race_nh_black_7days", -- Case by ethnicity Non Hispanic Black in the past 7 days
    "cumulative_deaths_agegroup", -- Deaths in age group 0 - 9 cumulative
    "cumulative_cases_agegroup_3", -- Cases by age group 30 - 39 cumulative
    "cumulative_tests_reportable", -- Total number of all PCR tests but only AG positive after April 1 , 2022
    "census_not_fully_vax", -- Number of CHA Reported hospital census patients not fully vaccinated
    "cumulative_cases_hisp_race_3", -- Case by ethnicity Non Hispanic Black cumulative
    "cumulative_cases", -- Total number of cases from the start of the pandemic
    "state_population", -- State Population Number
    "cumulative_deaths_gender", -- Cumulative female deaths
    "cumulative_deaths_agegroup_2", -- Deaths in age group 20 - 29 cumulative
    "cases_gender_other_7days", -- Cases by gender Other in the past 7 days
    "cumulative_deaths_gender_2", -- Cumulative other gender deaths
    "cases_age_group_unknown_7days", -- Cases by age group not available in the past 7 days
    "cumulative_deaths_hisp_race_1", -- Deaths by ethnicity Non-Hispanic American Indian or Alaskan Native cumulative
    "cumulative_deaths_hisp_race_2", -- Deaths by ethnicity Non-Hispanic Asian or Pacific Islander cumulative
    "fips", -- Connecticut State FIPS code
    "cumulative_deaths_agegroup_9" -- Deaths in age group unknown cumulative
FROM
    "ct-gov/covid19-state-level-data-archive-qmgw-5kp6:latest"."covid19_state_level_data_archive"
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 ct-gov/covid19-state-level-data-archive-qmgw-5kp6 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.ct.gov. When you queryct-gov/covid19-state-level-data-archive-qmgw-5kp6: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.ct.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 \
  "ct-gov/covid19-state-level-data-archive-qmgw-5kp6" \
  --handler-options '{
    "domain": "data.ct.gov",
    "tables": {
        "covid19_state_level_data_archive": "qmgw-5kp6"
    }
}'

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, ct-gov/covid19-state-level-data-archive-qmgw-5kp6 is just another Postgres schema.