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 commercial_district_customer_intercept_survey
table in this repository, by referencing it like:
"cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz:latest"."commercial_district_customer_intercept_survey"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"what_particular_businesses_are_you_visiting_today", -- An open response question which was coded by volunteers as data was inputted from paper copies.
"do_you_want_more_fitness_centers_gyms",
"do_you_want_more_apparel_clothing_stores",
"how_would_you_rate_the_presence_of_independent_businesses_in_th",
"how_would_you_rate_the_price_of_goods_and_services_available",
"do_you_want_more_pharmacies",
"do_you_want_more_specialty_food_stores",
"how_would_you_rate_the_quality_of_goods_and_services_available",
"do_you_want_more_movie_theaters_entertainment",
"do_you_want_more_sporting_goods_stores",
"do_you_want_more_accessory_stores_jewelry_shoes",
"how_many_times_a_month_do_you_come_to_district_for_entertainmen",
"how_important_is_the_attractiveness_of_the_district",
"do_you_want_more_restaurants_take_out",
"do_you_want_more_office_supply_stores",
"how_important_is_access_to_public_transit",
"how_would_you_rate_the_friendliness_of_the_district",
"how_important_is_the_availability_of_outdoor_activities_and_nig",
"do_you_want_more_farmer_s_markets",
"how_would_you_rate_the_outdoor_activities_and_nightlife_in_the_",
"how_would_you_rate_the_attractiveness_of_the_district",
"how_would_you_rate_the_safety_of_the_district",
"how_important_is_the_quality_of_goods_and_services_available",
"how_many_times_a_month_do_you_come_to_district_for_dining_enter", -- * Inman and Alewife grouped the dining and entertainment questions together, whereas previous surveys had separated them.
"do_you_want_more_florists",
"do_you_want_more_grocery_stores",
"do_you_want_more_convenience_stores",
"do_you_want_more_coffee_shops",
"do_you_want_more_barbers_hair_salons", -- Respondents answered yes, they wanted more of this business, or no, they did not want more of this business.
"what_would_you_keep_about_the_district", -- This open-answer response let respondents share what they would keep about the district.
"age", -- Respondents were asked their age.
"ranking_of_dry_cleaners_tailors", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_hardware_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_want_more_specialty_retail",
"do_you_want_more_restaurants_sit_down",
"ranking_of_grocery_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_home_goods", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_restaurants_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_florists", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"language", -- Respondents were asked what language, other than English, they speak at home.
"survey_year", -- The year in which that district was surveyed
"race", -- Respondents were asked about their race.
"ranking_of_pharmacy", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_movie_theaters_entertainment", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_go_to_school_in_cambridge", -- Respondents were asked if they go to school in Cambridge.
"ranking_of_restaurants_take_out", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"how_important_is_the_presence_of_cultural_events_in_the_distric",
"ranking_of_apparel_clothing_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_healthcare_dentists_doctors", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_specialty_food_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_fitness_centers_gyms", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"how_important_is_the_safety_of_the_district",
"ranking_of_food_trucks", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_farmer_s_markets", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"how_important_is_the_presence_of_independent_businesses",
"how_would_you_rate_the_business_hours_of_the_district",
"do_you_want_more_food_trucks",
"ranking_of_convenience_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_want_more_hardware_stores",
"how_would_you_rate_the_infrastructure_of_the_district",
"how_would_you_rate_the_cleanliness_of_the_district",
"how_important_is_the_range_of_goods_and_services_available",
"district", -- The district in which the survey was administered
"which_types_of_businesses_would_you_like_to_see_in_district", -- Some years, this was open response, whereas other years there was a menu to select from
"how_important_is_the_friendliness_of_the_district",
"ranking_of_book_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_work_in_cambridge", -- Respondents were asked if they work in Cambridge.
"how_would_you_rate_access_to_parking", -- Respondents were asked to rank each characteristic "good," "fair," or "poor."
"how_many_times_a_month_do_you_come_to_district_for_dining_in_ev",
"how_do_you_most_frequently_get_to_the_district", -- * The surveys for Alewife and Inman are the only ones that combined the dining/entertainment questions. To facilitate analysis, we took their responses to the combined question and put them in both the "dining" and "eating" questions that the other surveys were asked.
"how_important_is_the_cleanliness_of_the_district",
"what_is_the_primary_purpose_for_being_in_district_today", -- An open response question which was coded by volunteers as data was inputted from paper copies.
"please_tell_me_3_types_of_businesses_you_would_like_to_see_in_t", -- An open response question which was coded by volunteers as data was inputted from paper copies.
"do_you_want_more_healthcare_offices_doctors_dentists",
"what_would_make_you_shop_visit_more_often_in_district",
"what_discourages_you_from_shopping_in_district",
"ethinicity", -- Respondents were asked about their ethnicity.
"how_important_is_the_infrastructure_in_the_district",
"what_is_one_word_you_use_to_decribe_the_district", -- Respondents were asked to provide one word to describe the commercial district.
"what_would_you_change_abou_the_district", -- This open-answer response let respondents share what they would change about the district.
"what_would_you_eliminate_from_the_district", -- This open-answer response let respondents share what they would eliminate about the district.
"how_important_is_the_price_of_goods_and_services_available",
"how_would_you_rate_the_range_of_goods_and_services_available",
"ranking_of_office_supply_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_accessories_stores_shoes_jewelry", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"how_would_you_rate_the_cultural_attractions_of_the_district",
"how_important_are_the_business_hours_within_the_district",
"how_would_you_rate_access_to_public_transit",
"residency", -- Respondents provided their zip code of residency. We have removed these answers to protect respondents' privacy, but coded the zip codes based on whether they were in Cambridge or not.
"ranking_of_specialty_retail", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"how_long_is_your_average_visit_outside_of_work_to_district", -- Respondents shared how long their average visit was to the district, excluding work.
"ranking_of_barbers_hair_salons", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"homeownership", -- Respondents were asked whether they owned or rented their home.
"ranking_of_coffee_shops", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_want_more_book_stores",
"how_important_is_parking", -- Respondents were asked to assess importance of each characteristic "not very important," "important," and "very important."
"how_often_do_you_use_services_or_shops_in_district", -- Respondents shared how often they use services or shops in the district, excluding work.
"ranking_of_bars", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"ranking_of_sporting_goods", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
"do_you_want_more_bars",
"do_you_want_more_dry_cleaners_tailors",
"do_you_want_more_home_goods_stores",
"gender" -- Respondents were asked their gender.
FROM
"cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz:latest"."commercial_district_customer_intercept_survey"
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/commercial-district-customer-intercept-survey-ibuz-brbz
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 cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz: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/commercial-district-customer-intercept-survey-ibuz-brbz
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/commercial-district-customer-intercept-survey-ibuz-brbz:latest
This will download all the objects for the latest
tag of cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz
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/commercial-district-customer-intercept-survey-ibuz-brbz: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/commercial-district-customer-intercept-survey-ibuz-brbz: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/commercial-district-customer-intercept-survey-ibuz-brbz
is just another Postgres schema.