edmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx
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 edmontonians_perception_survey_safety_in_the_city table in this repository, by referencing it like:

"edmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx:latest"."edmontonians_perception_survey_safety_in_the_city"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "qd5b_which_of_the_following_best_describes_your_total_personal_", --  Profiling question. Question: Which of the following best describes your total personal annual income before taxes? || Possible Answers: Less than $20,000|Between $20,000 and $29,999|Between $30,000 and $49,999|Between $50,000 and $79,999|Between $80,000 and $119,999|$120,000 or more|Prefer not to answer 
    "qd5a_which_of_the_following_best_describes_your_total_annual_ho", --  Profiling question. Question: Which of the following best describes your total annual household income before taxes? || Possible Answers: Less than $20,000|Between $20,000 and $29,999|Between $30,000 and $49,999|Between $50,000 and $79,999|Between $80,000 and $119,999|$120,000 or more|Prefer not to answer 
    "qdr_city_quadrant", --  Profiling question. Question: City Quadrant? || Possible Answers: NW|NE|SE|SW|Other 
    "qe_fsa", --  Forward Sortation Area (first 3 characters of postal code) 
    "d3_age", --  Profiling question. Question: Your age? || Possible Answers: Under 18 years old|18 - 24|25 - 34|35 - 44|45 - 54|55 - 64|65 years and over|Refused 
    "d1_gender", --  Profiling question. Question: Your gender? || Possible Answers: Female|Male 
    "q14i_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel prevention is an approach to reduce crime || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q14g_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe using the bus system || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q14f_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe using the LRT || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q14b_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe in my home || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q13c_how_much_do_you_agree_or_disagree_that_edmonton_is_a_safe_", --  Question: . How much do you agree or disagree that - Edmonton is a safe city at night || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q13b_how_much_do_you_agree_or_disagree_that_edmonton_is_a_safe_", --  Question: . How much do you agree or disagree that - Edmonton is a safe city during the day || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q13_neither_agree_or_disagreea_how_much_do_you_agree_or_disagre", --  Question: . How much do you agree or disagree that - Overall, I feel Edmonton is a safe city || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "qd8_did_you_vote_in_the_most_recent_municipal_election_for_the_", --  Profiling question. Question: Did you vote in the most recent municipal election for the City of Edmonton? || Possible Answers: Yes|No|I was not eligible 
    "qd3_what_is_the_highest_level_of_education_you_have_achieved", --  Profiling question. Question: What is the highest level of education you have achieved?? || Possible Answers: Less than high school|Graduated high school|Graduated college, technical or vocational school|Graduated university|Prefer not to answer 
    "d1a_as_different_people_may_have_different_views_and_needs_the_", --  Question: As different people may have different views and needs, including yourself, how many people are there in your household? 
    "d7_which_of_the_following_best_describes_your_marital_status_ar", --  Profiling question. Question: Which of the following best describes your marital status? Are you... || Possible Answers: Single, never married|Married or common law|Separated, divorced, widowed|Don't know/Prefer not to answer 
    "d2b_between_10_and_17_years_of_age", --  Question: How many people in your household are: Between 10 and 17 years of age 
    "qd10_and_what_type_of_residence_do_you_live_in", --  Profiling question. Question: What type of residence do you live in? || Possible Answers: House|Duplex|Four-plex|Apartment|Condo|Townhouse|Other 
    "qd4_are_you_currently", --  Profiling question. Question: Which of the following best describes your employment status, are you currently... || Possible Answers: Working full time|Working part time|A student|Not working outside the home|Retired|Prefer not to answer 
    "d2d_over_65_years_of_age", -- Question: How many people in your household are: Over 65 years of age 
    "d2a_under_10_years_of_age", --  Question: How many people in your household are: Under 10 years of age 
    "q14c_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe in my local neighbourhood parks || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "completion_date", --  Date the respondent did the survey 
    "qd11_were_you", --  Profiling question. Question: Were you? || Possible Answers: Born in Canada|Moved to Canada from somewhere else 
    "qd9_do_you_currently_own_or_rent_your_place_of_residence", --  Profiling question. Question: Do you currently own or rent your place of residence? || Possible Answers: Own|Rent 
    "d2c_between_18_and_65_years_of_age", -- Question: How many people in your household are: Between 18 and 65 years of age 
    "qd7_do_you_work_for_the_city_of_edmonton", --  Profiling question. Question: Do you work for the City of Edmonton? || Possible Answers: Yes|No 
    "q14e_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe in the river valley parks || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "qd6_what_is_the_primary_language_spoken_in_your_household", --  Profiling question. Question: What is the primary language spoken in your household? || Possible Answers: English|French|Others 
    "d2tot_total_children_in_hh", --  Question: Total number of children in your household? 
    "qd_how_long_have_you_lived_in_edmonton", --  Profiling question. Question: How long have you lived in Edmonton? || Possible Answers: Less than 6 months|6 months to less than 1 year|1 year to less than 3 years|3 years to less than 5 years|5 years or more 
    "q14d_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe walking downtown || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "calldurationinseconds", --  Duration of the call in seconds 
    "q14h_how_much_do_you_agree_or_disagree_about_the_city_of_edmont", --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe leaving my residence or property unattended || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
    "q14a_how_much_do_you_agree_or_disagree_about_the_city_of_edmont" --  Question: . How much do you agree or disagree about the city of Edmonton. - I feel safe walking in my neighbourhood || Possible Answers: 5 - Strongly Agree|4 - Agree|3 - Neither agree or disagree|2 - Disagree|1 - Strongly Disagree|Don't know 
FROM
    "edmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx:latest"."edmontonians_perception_survey_safety_in_the_city"
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/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.edmonton.ca. When you queryedmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx: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.edmonton.ca, 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 \
  "edmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx" \
  --handler-options '{
    "domain": "data.edmonton.ca",
    "tables": {
        "edmontonians_perception_survey_safety_in_the_city": "f2ri-59cx"
    }
}'

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, edmonton-ca/edmontonians-perception-survey-safety-in-the-city-f2ri-59cx is just another Postgres schema.