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 2024_citywide_retention_audit_employee_survey
table in this repository, by referencing it like:
"datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s:latest"."2024_citywide_retention_audit_employee_survey"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"q6c_commitment_to_public", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q6d_compensation_salary", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q9b_i_feel_valued_by_my", -- Question 9 - Please rank your agreement with the following statements
"q6g_retirement_pension", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q6h_telework_flexible_work", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q6a_benefits_including", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q7_do_the_training_and", -- Question 7 - Do the training and development opportunities offered by your department improve your desire to stay with the City?
"q11_does_the_retention_program", -- Question 11 - Does the retention program offered by your department improve your desire to stay with the City? Retention program refers to any monetary incentives added to base pay.
"q10_what_department_are_you", -- Question 10 - What Department are you with?
"q9d_i_would_recommend_the", -- Question 9 - Please rank your agreement with the following statements
"q9a_i_am_satisfied_with_my", -- Question 9 - Please rank your agreement with the following statements
"q4c_i_intend_to_retire_from", -- Question 4 - Please rank how likely the following options are for you.
"altq3c_better_compensation", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"q8_do_the_training_and", -- Question 8 - Do the training and development opportunities offered by the City improve your desire to stay with the City?
"altq3d_better_management", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"q6b_career_advancement", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q9c_i_would_recommend_my", -- Question 9 - Please rank your agreement with the following statements
"altq3f_more_opportunities", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"q4b_i_intend_to_be_working", -- Question 4 - Please rank how likely the following options are for you.
"q5_since_becoming_a_city", -- Question 5 - Since becoming a City of Austin employee, when was the last time you applied for a job outside the City?
"q6e_fair_and_equitable", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"altq3a_additional_career", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"altq3b_attractive_retention", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"q6f_management_co_workers", -- Question 6 - How important are each of the following options in keeping you employed with the City?
"q4a_i_intend_to_be_working", -- Question 4 - Please rank how likely the following options are for you.
"altq3e_dissatisfaction_with", -- Question 3 - How much did the following factors influence your desire to transfer departments? (only asked if answered "yes" to Question 2
"q2_have_you_ever_transferred", -- Question 2 - Have you ever transferred departments within the City?
"survey_response_number", -- Added index for analysis
"q1_how_many_years_have_you" -- Question 1 - How many years have you worked for the City?
FROM
"datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s:latest"."2024_citywide_retention_audit_employee_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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s
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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s: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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s
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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s:latest
This will download all the objects for the latest
tag of datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s
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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s: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 datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s: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, datahub-austintexas-gov/2024-citywide-retention-audit-employee-survey-nhy2-6a3s
is just another Postgres schema.