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 snow_and_ice_control_service_levels_feb_2022
table in this repository, by referencing it like:
"edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp:latest"."snow_and_ice_control_service_levels_feb_2022"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"d9_other_snow_assistance", -- Demographic Qs: Aware of; Use; Neither aware nor use; Prefer not to answer
"d9_the_community_snow_to", -- Demographic Qs: Aware of; Use; Neither aware nor use; Prefer not to answer
"d7_prefer_not_to_answer", -- Demographic Qs: 1: Yes; 0: No
"d7_a_person_who_is_deaf_or", -- Demographic Qs: 1: Yes; 0: No
"d7_a_person_with_a_physical", -- Demographic Qs: 1: Yes; 0: No
"d6_person_with_mobility", -- Demographic Qs: 1: Yes; 0: No
"d6_someone_who_supports_a", -- Demographic Qs: 1: Yes; 0: No
"d6_person_with_a_disability", -- Demographic Qs: 1: Yes; 0: No
"d5", -- Demographic Qs: Under $30,000; $30,000 to $59,999; $60,000 to $99,999; $100,000 to $149,999; $150,000 and over; I prefer not to answer
"d1_walking_running", -- Demographic Qs: 1: Yes; 0: No
"d1_cycling", -- Demographic Qs: 1: Yes; 0: No
"q6_the_community_parking", -- Signage related statements: 5-Strongly Agree; 4-Somewhat Agree; 3-Neither Agree nor Disagree; 2-Somewhat Disagree; 1- Strongly Disagree; I did not see the signs / Not Applicable
"q3_enhancing_our_service", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_more_frequent_plowing_2", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_more_frequent_plowing_1", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_more_frequent_plowing", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_using_alternative_materials", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_city_clearing_all_privately", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q2", -- Alternative Material Use: 1: Yes; 2: No; 3: Unsure; 4:Other (Pl Specify)
"q1", -- Satisfaction levels: 5: Very Satisfied; 4:; 3:; 2:; 1: Not Satisfied
"completiondate", -- Date and Time respondent completed survey
"responseid", -- Unique respondent identifier
"d9_accessible_parking_stall", -- Demographic Qs: Aware of; Use; Neither aware nor use; Prefer not to answer
"d7_a_person_with_a_psychiatric", -- Demographic Qs: 1: Yes; 0: No
"d6_i_prefer_not_to_answer", -- Demographic Qs: 1: Yes; 0: No
"d6_immigrant_or_new_canadian", -- Demographic Qs: 1: Yes; 0: No
"d6_lgbtq2s_person", -- Demographic Qs: 1: Yes; 0: No
"d4", -- Demographic Qs: Yes; No; Unsure/not applicable
"d2", -- Demographic Qs: Park Use: More than 5 times; 3-4 times; 1-2 times; I did not use parks or open spaces for leisure
"q5_faster_response_to_snow", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q5_time_and_location_specific", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q3_clearing_unprotected_bike", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"responsedate", -- Date and Time respondent began survey
"q9", -- Tax increase support: Strongly supportive; Somewhat supportive; Neither supportive nor against; Somewhat against; Strongly against
"d6_none_of_the_above", -- Demographic Qs: 1: Yes; 0: No
"d6_a_racialized_person", -- Demographic Qs: 1: Yes; 0: No
"d6_indigenous_person", -- Demographic Qs: 1: Yes; 0: No
"d7_a_neurodiverse_person", -- Demographic Qs: 1: Yes; 0: No
"d3", -- Demographic Qs: Yes; No; Unsure/not applicable
"d1_personal_vehicle_driver", -- Demographic Qs: 1: Yes; 0: No
"q8", -- Blading Work preferance: Work only between 7 a.m. and 7 p.m; Work longer hours (up to 24 hours); No preference; Not applicable (don’t have or drive a vehicle
"q6_the_signs_have_enough", -- Signage related statements: 5-Strongly Agree; 4-Somewhat Agree; 3-Neither Agree nor Disagree; 2-Somewhat Disagree; 1- Strongly Disagree; I did not see the signs / Not Applicable
"q5_maintaining_culs_de_sac", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q5_shorten_the_length_of", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q5_removing_all_windrows", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q5_removing_additional", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q5_an_online_map_or_digital", -- Importance of service enhancements: 5: Very Important; 4:; 3:; 2:; 1: Not Important
"q4", -- Option preference: A: Clearing snow to bare pavement; B: Leave a snowpack on the road; I do not have a preference
"d7_none_of_the_above", -- Demographic Qs: 1: Yes; 0: No
"d7_a_person_with_a", -- Demographic Qs: 1: Yes; 0: No
"d7_a_person_who_is_visually", -- Demographic Qs: 1: Yes; 0: No
"d6_a_person_who_walks_with", -- Demographic Qs: 1: Yes; 0: No
"d4a", -- Demographic Qs: Single detached home; Townhouse, duplex, or fourplex; Condo/apartment; Other (Please specify); Prefer not to answer
"d1_public_transit_bus_lrt", -- Demographic Qs: 1: Yes; 0: No
"d1_other_specify", -- Demographic Qs: 1: Yes; 0: No
"d10", -- Demographic Qs: Yes; No; Unsure; Not applicable; Prefer not to answer
"status" -- Survey Status
FROM
"edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp:latest"."snow_and_ice_control_service_levels_feb_2022"
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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp
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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp: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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp
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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp:latest
This will download all the objects for the latest
tag of edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp
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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp: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 edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp: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, edmonton-ca/snow-and-ice-control-service-levels-feb-2022-d2m8-w3wp
is just another Postgres schema.