cityofchicago/budget-survey-2021-h6r6-h5c9
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 budget_survey_2021 table in this repository, by referencing it like:

"cityofchicago/budget-survey-2021-h6r6-h5c9:latest"."budget_survey_2021"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "reallocate_from_police", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "additional_resources_cultural_affairs_and_special_events", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "additional_resources_public_health", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "_1000_assignment_cultural_affairs_and_special_events", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "additional_resources_type", -- Whether the respondent answered the question: "If you selected a program area(s) that you believe requires additional resources, what kinds of resources do you think are needed?"
    "reallocate_from_none", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "increase_revenue_garbage_fee", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "increase_revenue_fuel_tax", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "increase_revenue_other", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "counter_column", -- This is an additional column, set to 1 for all records, to allow for certain types of charts and aggregations.
    "date", -- The date on which the respondent completed the survey.
    "reallocate_from_regulatory", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "reallocate_from_community", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "additional_resources_regulatory", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "additional_resources_streets_and_sanitation", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "zip_code", -- The respondent's reported home ZIP Code.
    "_1000_assignment_police", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "increase_revenue_increase_sales_tax", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "open_ended_response", -- Did the person enter a response to the final question that allowed for open-ended comments or suggestions?
    "reallocate_from_libraries", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "_1000_assignment_other_public_safety", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "_1000_assignment_infrastructure_services", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "additional_resources_other_public_safety", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "additional_resources_libraries", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "additional_resources_source_increase_revenue", -- Whether the respondent would favor this option as a source of additional resources for the previous set of questions.
    "additional_resources_source_other", -- Whether the respondent would favor this option as a source of additional resources for the previous set of questions.
    "_1000_assignment_public_health", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "_1000_assignment_libraries", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "increase_revenue_none", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "rank_regulatory", -- Response to the question: "Rank these City services in order of most importance to you."
    "_1000_assignment_community", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "additional_resources_police", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "_1000_assignment_streets_and_sanitation", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "reallocate_from_cultural_affairs_and_special_events", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "rank_infrastructure", -- Response to the question: "Rank these City services in order of most importance to you."
    "additional_resources_source_reallocate_existing_funding", -- Whether the respondent would favor this option as a source of additional resources for the previous set of questions.
    "increase_revenue_expand_sales_tax", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "reallocate_from_infrastructure_services", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "rank_cultural_affairs_and_special_events", -- Response to the question: "Rank these City services in order of most importance to you."
    "rank_city_development", -- Response to the question: "Rank these City services in order of most importance to you."
    "increase_revenue_property_tax", -- Response to the question: "If you selected increase existing revenue or introduce new revenue sources, which of the following examples of revenue options would you choose in order to provide additional resources?"
    "additional_resources_infrastructure_services", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "additional_resources_city_development", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "reallocate_from_public_health", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "rank_libraries", -- Response to the question: "Rank these City services in order of most importance to you."
    "additional_resources_community", -- Response to the question: "Which of the following general categories of City services do you believe require additional resources, if any?"
    "rank_community", -- Response to the question: "Rank these City services in order of most importance to you."
    "rank_public_health", -- Response to the question: "Rank these City services in order of most importance to you."
    "rank_other_public_safety", -- Response to the question: "Rank these City services in order of most importance to you."
    "rank_streets_and_sanitation", -- Response to the question: "Rank these City services in order of most importance to you."
    "rank_police", -- Response to the question: "Rank these City services in order of most importance to you."
    "_1000_assignment_city_development", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "reallocate_from_city_development", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "reallocate_from_streets_and_sanitation", -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
    "_1000_assignment_regulatory", -- Amount of a hypothetical $1000 allocated to this area. Negative and blank values have been converted to $0 if any question is this series was answered. If the total allocated was above or below $1000, all values have been adjusted proportionally to bring the total to $1000.
    "reallocate_from_other_public_safety" -- Response to the question: "If you selected reallocate funding above in order to provide funding for other priority programs or services, which of these areas would you reallocate funding from?"
FROM
    "cityofchicago/budget-survey-2021-h6r6-h5c9:latest"."budget_survey_2021"
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 cityofchicago/budget-survey-2021-h6r6-h5c9 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 cityofchicago/budget-survey-2021-h6r6-h5c9: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 cityofchicago/budget-survey-2021-h6r6-h5c9

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 cityofchicago/budget-survey-2021-h6r6-h5c9:latest

This will download all the objects for the latest tag of cityofchicago/budget-survey-2021-h6r6-h5c9 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 cityofchicago/budget-survey-2021-h6r6-h5c9: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 cityofchicago/budget-survey-2021-h6r6-h5c9: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, cityofchicago/budget-survey-2021-h6r6-h5c9 is just another Postgres schema.

Related Documentation:

Loading...