cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z
Loading...

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 cambridge_homeless_pointintime_count_data_20122023 table in this repository, by referencing it like:

"cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z:latest"."cambridge_homeless_pointintime_count_data_20122023"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "number_of_parenting_youth", -- Number of Parenting Youth under age 25. (Field added in 2015)
    "white", -- Number of persons who identify as White. (Field added in 2014)
    "victims_of_domestic_violence", -- Number of adults who are victims of domestic violence
    "number_of_households", -- Number of Households
    "number_of_persons", -- Number of Persons
    "persons_over_age_24", -- Number of persons over age 24. (Field added in 2013)
    "number_of_unaccompanied_youth", -- Number of single individuals under age 25 not accompanied by parent or guardian. (Field added in 2015)
    "non_hispanic_non_latino", -- Number of persons who identify as Non-Hispanic/Non-Latino. (Field added in 2014)
    "black_or_african_american", -- Number of persons who identify as Black or African-American. (Field added in 2014)
    "asian", -- Number of persons who identify as Asian. (Field added in 2014)
    "adults_with_substance_use_disorder", -- Number of adults with Substance Use Disorder
    "chronically_homeless_persons", -- Number of persons meeting definition of chronically homeless in effect on PIT night. The current definition includes persons with a disabling condition who have either experienced homelessness continuously for one year or who have experienced homelessness four or more times in the last three years where each episode was at least 7 days and the four episodes add up to at least 12 months.
    "year", -- Year of the Point-in-Time (PIT) count
    "total_beds_for_households_without_children", -- Total Beds for Households without Children available (occupied or not) on the PIT night, including seasonal and overflow shelter beds.
    "number_of_veterans", -- Number of Veterans
    "don_t_identify_as_male_female_or_transgender", -- Number of persons who don't identify as male, female or transgender. (Field added in 2017)
    "pit_date", -- Date of the Point In Time count
    "persons_in_households_with_children", -- Number of persons in households with children
    "transgender", -- Number of transgender persons. (Field added in 2014)
    "children_under_age_18", -- Number of children under age 18. (Field added in 2013)
    "native_hawaiian_or_other_pacific_islander", -- Number of persons who identify as Native Hawaiian or Other Pacific Islander. (Field added in 2014)  
    "multiple_races", -- Number of persons who identify as Multiple Races. (Field added in 2014)
    "hispanic_latino", -- Number of persons who identify as Hispanic/Latino. (Field added in 2014)
    "single_individuals", -- Number of single individuals
    "male", -- Number of males. (Field added in 2014)
    "american_indian_or_alaska_native", -- Number of persons who identify as American Indian or Alaska Native. (Field added in 2014)
    "total_beds_for_households_with_children", -- Total Beds for Households with Children available (occupied or not) on the PIT night.
    "persons_age_18_to_24", -- Number of persons age 18 to 24. (Field added in 2013)
    "female", -- Number of females. (Field added in 2014)
    "total_units_for_households_with_children", -- Total Units for Households with Children available (occupied or not) on the PIT night.
    "adults_with_serious_mental_illness", -- Number of adults with Serious Mental Illness
    "adults_with_hiv_aids", -- Number of adults with HIV/AIDS
    "housing_type" -- Emergency Shelter, Transitional Housing, or Unsheltered
FROM
    "cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z:latest"."cambridge_homeless_pointintime_count_data_20122023"
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 cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z with SQL in under 60 seconds.

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, 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 cloneand sgr checkout.

Cloning Data

Because cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z: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 cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z

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 cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z:latest

This will download all the objects for the latest tag of cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z 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 cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z: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 cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z: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, cambridgema-gov/cambridge-homeless-pointintime-count-data-20122023-ify2-i22z is just another Postgres schema.

Related Documentation:

Loading...