kcmo/311-call-center-reported-issues-d4px-6rwg
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 311_call_center_reported_issues table in this repository, by referencing it like:

"kcmo/311-call-center-reported-issues-d4px-6rwg:latest"."311_call_center_reported_issues"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "resolved_date", -- Date and time that the issue was marked as resolved.
    "department_work_group", -- Work group assigned to this type of Issue/Subissue by default. Usually part of a City Department or Division.
    "lat_long",
    "workorder_", -- For integrated systems such as Cartegraph or EnerGov, the other system will have its own identifier column. 
    "open_date_time", -- Date and time that the issue was reported originally.
    "additional_questions", -- Any additional questions configured in MyCivic to collect information about the issue. Format concatenates all questions into a single field.
    "incident_address", -- The address originally reported 
    "days_to_close", -- Days between opening and closing the reported issue, rounded down. If the issue is still open, this is the number of days it has been open. 
    ":@computed_region_qizh_zmq5", -- This column was automatically created in order to record in what polygon from the dataset 'City Council Districts (effective 2023)' (qizh-zmq5) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_kk66_ngf4", -- This column was automatically created in order to record in what polygon from the dataset 'Neighborhood Census' (kk66-ngf4) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_9t2m_phkm", -- This column was automatically created in order to record in what polygon from the dataset 'Council Districts' (9t2m-phkm) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_my34_vmp8", -- This column was automatically created in order to record in what polygon from the dataset 'County Boundary' (my34-vmp8) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_vrdq_ghvi", -- This column was automatically created in order to record in what polygon from the dataset 'Community Improvement District' (vrdq-ghvi) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "issue_type", -- Broad category of issue.
    "longitude",
    "report_source", -- Source of the reported issue; this may be through the mobile apps, the calltakers within the City, or the web form.
    "issue_sub_type", -- Narrower subcategory of issue.
    "latitude",
    "last_updated", -- last update for the issue. may not be accurate or filled in for cases created prior to June 2021.
    "council_district", -- Councilmatic district of the reported issue's address or location.
    "source_category", -- Aggregate field, combining externally-driven sources (web, Android and iOS) and internally-generated sources (phone, email, fax, etc)
    "current_status", -- Current status of the reported issue.
    "reported_issue", -- Issue identifier. Format varies based on which work order system the issue belongs to.
    ":@computed_region_w4hf_t6bp", -- This column was automatically created in order to record in what polygon from the dataset 'Zip Codes' (w4hf-t6bp) the point in column 'lat_long' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_k7in_q28t"
FROM
    "kcmo/311-call-center-reported-issues-d4px-6rwg:latest"."311_call_center_reported_issues"
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 kcmo/311-call-center-reported-issues-d4px-6rwg 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 kcmo/311-call-center-reported-issues-d4px-6rwg: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 kcmo/311-call-center-reported-issues-d4px-6rwg

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 kcmo/311-call-center-reported-issues-d4px-6rwg:latest

This will download all the objects for the latest tag of kcmo/311-call-center-reported-issues-d4px-6rwg 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 kcmo/311-call-center-reported-issues-d4px-6rwg: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 kcmo/311-call-center-reported-issues-d4px-6rwg: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, kcmo/311-call-center-reported-issues-d4px-6rwg is just another Postgres schema.

Related Documentation:

Loading...