citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3
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 prcf_parks_ranger_reports table in this repository, by referencing it like:

"citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3:latest"."prcf_parks_ranger_reports"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "fire_dept_call", -- Number of calls to Fire Department
    ":@computed_region_v3p2_n653", -- This column was automatically created in order to record in what polygon from the dataset 'Arizona Postal Code Boundaries v1.0' (v3p2-n653) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_by5m_u9f6", -- This column was automatically created in order to record in what polygon from the dataset 'Council District vJun2022' (by5m-u9f6) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_yvgd_jnii", -- This column was automatically created in order to record in what polygon from the dataset 'Hexagon 8th Square Mile Project' (yvgd-jnii) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_5spd_7gy6", -- This column was automatically created in order to record in what polygon from the dataset 'Mesa Census Tracts To City Boundary v2022' (5spd-7gy6) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_jbri_cbif", -- This column was automatically created in order to record in what polygon from the dataset 'Parks and Basins Boundaries' (jbri-cbif) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_4svm_3hip", -- This column was automatically created in order to record in what polygon from the dataset 'Mesa Census Tracts' (4svm-3hip) the point in column 'geometry' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "vehicle_in_park_warnings", -- Number of Vehicle in Park Warnings
    "warrant_arrests", -- Number of Warrant Arrests
    "total_warnings", -- Total Warnings
    "total_call_outs", -- Total number of call outs 
    "glass_citations", -- Number of glass citations
    "opioid_fentanyl_contact", -- Number of Opioid Fentanyl Contacts
    "geometry", -- Geometry
    "total_patrons", -- Total number of patrons
    "dog_warning", -- Number of Dog Warnings
    "glass_warnings", -- Number of glass warnings
    "shopping_carts_warning", -- Number of shopping cart warnings
    "litter_citations", -- Number of litter citations
    "vehicle_in_park_citations", -- Number of Vehicle in Park Citations
    "homeless_citations", -- Number of citations given to the homeless in Parks
    "alcohol_warnings", -- Number of alcohol warnings
    "misc_warnings", -- Number of miscellaneous warnings
    "vending_warnings", -- Number of vending warnings
    "visit_id", -- Visit ID
    "ranger_name", -- Name of park ranger reporting contacts
    "paths", -- Number of paths visited 
    "standard_citations", -- Total number of citations issued
    "camping_warnings", -- Number of camping warnings
    "parking_citations", -- Number of parking citations
    "total_warnings_citations", -- Total Warnings & Citations
    "rowid", -- Unique Row Identifier
    "reporting_month", -- Name of the month when reported contact occurred
    "p_g", -- Number of playgrounds visited 
    "after_hours_warnings", -- Number of After Hour warnings
    "parking_warnings", -- Number of Parking Warnings
    "vending_citations", -- Number of vending citations
    "police_call_outs", -- Number of Police Call Outs
    "dog_citations", -- Number of Dog Citations
    "shopping_carts_citations", -- Number of shopping cart citations
    "camping_citations", -- Number of camping citations
    "basin_call_outs", -- Number of Basin Call Outs
    "homeless_arrests", -- Number of arrests the Mesa Police handled after being contacted by the Park Rangers
    "reporting_year", -- Year when reported contact occurred
    "calls_for_service", -- Calls for Service
    "homeless_assists", -- Number of homeless assists that the Park Rangers handled
    "misc_citations", -- Number of miscellaneous citations
    "smoking_citations", -- Number of smoking citations
    "location", -- Name of the Park Visited
    "reporting_date", -- Day/Month/Year in date format of the day when reported contact occurred
    "facility_id", -- Unique identifier for each park or basin. Parks are indicated by PKPK followed by a number, Basins are indicated by PKBN followed be a number.
    "latitude", -- Latitude
    "after_hours_citation", -- Number of After Hour citations
    "r_r", -- Number of restroom facilities visited in the parks
    "homeless_warnings", -- Number of warnings given to the homeless in Parks
    "alcohol_citation", -- Number of alcohol citations
    "community_court", -- Number of homeless contacts that were provided the opportunity to go to Community Court – handled by the Mesa Police Department
    "total_citations", -- Total Citations
    "longitude", -- Longitude
    "litter_warnings", -- Number of litter warnings
    "patron_concerns", -- Number of Patron Concerns
    "smoking_warnings", -- Number of smoking warnings
    "object_id", -- Object ID
    "created_date", -- Created Date
    "of_sites_visited", -- Number of parks sites visited 
    "workorders", -- Number of work orders submitted to maintenance
    "standard_warnings", -- Total number of warnings issued
    "homeless_contacted", -- Number of homeless that are contacted
    "patron_assists" -- Number of Patron Assists
FROM
    "citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3:latest"."prcf_parks_ranger_reports"
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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3 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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3: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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3

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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3:latest

This will download all the objects for the latest tag of citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3 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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3: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 citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3: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, citydata-mesaaz-gov/prcf-parks-ranger-reports-daky-m4y3 is just another Postgres schema.

Related Documentation:

Loading...