norfolk-gov/permits-and-inspections-bnrb-u445
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 permits_and_inspections table in this repository, by referencing it like:

"norfolk-gov/permits-and-inspections-bnrb-u445:latest"."permits_and_inspections"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "permit_application_connection", -- Designates who has applied for the permit for a specific job
    "permit_zip_code", -- The zip code for the location of the issued permit
    "ward", -- Ward the issued permit location is located in
    "super_ward", -- Super Ward the issued permit is located in
    "geocoded_column", -- Georeferenced column of XY coordinates of the location of the permit issued
    "ftpuser", -- Permit number assigned
    "permit_use_type", -- Use type classification the permit is issued for
    "permit_finaled_date", -- Date the permit was finalized
    "permit_next_annual_inspection", -- Annual inspection date for the renewal of permit
    "permit_address", -- Address the permit is assigned to
    "permit_application_date", -- Date permit application was submitted on
    "permit_issue_date", -- Date the permit has been issued on
    "permit_type", -- Type of permit issued (i.e. building, mechanical, plumbing, fire, electrical, etc.)
    "permit_building_flood_zone", -- Designates if the permit being issued structure (building, deck, porch) is in the flood zone
    ":@computed_region_b3ci_nw94", -- This column was automatically created in order to record in what polygon from the dataset 'Civic Leagues_uniq_prepend' (b3ci-nw94) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_x6fk_ihs5", -- This column was automatically created in order to record in what polygon from the dataset 'Civic Leagues' (x6fk-ihs5) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_25t2_rbz7", -- This column was automatically created in order to record in what polygon from the dataset 'US Counties' (25t2-rbz7) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_38t5_wna6", -- This column was automatically created in order to record in what polygon from the dataset 'Civic Leagues_from_ktui_fihj' (38t5-wna6) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "parcel_gpin", -- Grid Parcel Identification Number generated to provide a unique identifier for each parcel
    "permit_parcel_flood_zone", -- Designates if permit being issued is located on parcel in the flood zone
    "permit_narrow_lot", -- Designates if the permit is for a narrow lot
    "permit_use_group", -- Coding classification for the use groups
    "permit_occupancy_required", -- Designates if the permit will require a certificate of occupancy to be issued
    "permit_next_5_year_inspection", -- Five-year date of the next inspection for renewal of permit
    "inspection_completed_date", -- The date the inspection was completed
    "inspection_scheduled_date", -- The date the inspection was scheduled
    "inspection_status", -- Current status of the inspection
    "inspection_number", -- Inspection number assigned
    "inspection_group", -- Group responsible for the inspection (i.e. fire, electrical, codes/zoning, etc.)
    "inspection_type", -- Category code and detail type of the inspection
    "permit_work_items", -- Designates if there are work items associated with the permit
    "permit_use_group_info", -- Type of use group designation for the permit issued
    "permit_project_cost", -- Cost of the project the permit is issued for
    "permit_total_balance", -- Total balance due on the issued permit
    "permit_total_payments", -- Total amount payment made on the issued permit
    "permit_total_fee", -- Total fee amount for the issued permit
    "permit_building_square_footage", -- The square footage of the building on the issued permit
    "permit_structure", -- The structure type the permit is issued for (i.e. building, porch, deck, garage, etc.)
    "permit_description", -- Description of work the permit is issued for
    "permit_work_type", -- Type of work the permit allows for (i.e. new, replacement, service upgrade)
    "permit_use_class", -- Use class assigned on the permit (residential or commercial)
    "permit_status" -- Status of the permit
FROM
    "norfolk-gov/permits-and-inspections-bnrb-u445:latest"."permits_and_inspections"
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 norfolk-gov/permits-and-inspections-bnrb-u445 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 norfolk-gov/permits-and-inspections-bnrb-u445: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 norfolk-gov/permits-and-inspections-bnrb-u445

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 norfolk-gov/permits-and-inspections-bnrb-u445:latest

This will download all the objects for the latest tag of norfolk-gov/permits-and-inspections-bnrb-u445 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 norfolk-gov/permits-and-inspections-bnrb-u445: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 norfolk-gov/permits-and-inspections-bnrb-u445: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, norfolk-gov/permits-and-inspections-bnrb-u445 is just another Postgres schema.

Related Documentation:

Loading...