brla-gov/baton-rouge-fire-incidents-dakq-4sda
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 baton_rouge_fire_incidents table in this repository, by referencing it like:

"brla-gov/baton-rouge-fire-incidents-dakq-4sda:latest"."baton_rouge_fire_incidents"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "alarms", -- Actual number of alarms (method of measuring incident severity) transmitted for the incident
    ":@computed_region_8tu6_j4iw",
    ":@computed_region_hfgy_t898",
    ":@computed_region_92rf_uvyc",
    ":@computed_region_qfmj_2fwi",
    ":@computed_region_tqy7_429i",
    ":@computed_region_9v63_zwfd",
    ":@computed_region_j2jn_cpbq",
    ":@computed_region_tm4z_r3je",
    ":@computed_region_8siy_mghw",
    ":@computed_region_i2e6_956r",
    ":@computed_region_uvg4_nwq8",
    ":@computed_region_jrqt_zu77",
    ":@computed_region_ntzg_c2w3",
    "st_prefix", -- Directional descriptor appearing before a street name
    "app_other", -- Total number of 'other' apparatus that responded to the incident
    "ctrl_time", -- Time of day that the fire was under control
    "formattedstreet", -- Complete street address
    "state", -- State where the incident occurred
    "per_rescue", -- Total number of Rescue personnel that responded to the incident
    "inci_type", -- The code for actual situation that fire personnel found on the scene when they arrived
    "city", -- City where the incident occurred 
    "zip", -- Five digit numerical postal code assigned by U.S. Postal Service 
    "xst_suffix", -- Nearest cross street type descriptor appearing after a street name
    "st_suffix", -- Directional descriptor appearing after a street name
    "geolocation", -- Address uses for geo-coding
    "inj_fs", -- Number of Fire service personnel injury
    "fatal_fs", -- Number of Fire service personnel fatality
    "fatal_civ", -- Number of Civilian fatality
    "number", -- The Number or milepost of specific location where the incident occurred
    "xstreet", -- Nearest cross street name where the incident occurred
    "exp_no", -- Identifies each separate property type involved in the fire
    "street", -- Street name where the incident occurred
    "apt_room", -- The number or letter of the specific apartment, suite, or room where the incident occurred
    "inci_no", -- Fire department internal file number
    "ctrl_date", -- Actual month, day, and year that the fire was under control
    "disp_time", -- Time of day when the unit was dispatched
    "app_rescue", -- Total number of Rescue apparatus that responded to the incident
    "geolocation_address",
    "prop_loss", -- Estimate of total property dollar loss
    "clr_time", -- Time of day when the unit is cleared from the incident and is available for new duty
    "xst_prefix", -- Nearest cross street directional descriptor appearing before a street name
    "rural", -- Scattered small communities and isolated family dwellings
    "inj_civ", -- Number of Civilian injury
    "app_ems", -- Total number of EMS apparatus that responded to the incident
    "prop_val", -- Estimate of total property value
    "per_ems", -- Total number of EMS personnel that responded to the incident
    "clr_date", -- Actual month, day, and year when the unit is cleared from the incident and is available for new duty
    "geolocation_state",
    "inci_descript", -- Description of the actual situation that fire personnel found on the scene when they arrived
    "cont_val", -- Estimate of total contents value
    "app_supp", -- Total number of suppression apparatus that responded to the incident
    "per_other", -- Total number of 'other' personnel that responded to the incident
    "cause_ign_descript", -- The description of general casual factor that resulted in a heat source igniting a combustible material
    "st_type", -- Street type descriptor appearing after a street name
    "disp_date", -- Month, day, and year when the unit was dispatched
    "geolocation_zip",
    "per_supp", -- Total number of suppression personnel that responded to the incident
    "cont_loss", -- Estimate of total contents dollar loss
    "xst_type", -- Nearest cross street type descriptor appearing after a street name
    "cause_ign", -- The code of general casual factor that resulted in a heat source igniting a combustible material
    "geolocation_city"
FROM
    "brla-gov/baton-rouge-fire-incidents-dakq-4sda:latest"."baton_rouge_fire_incidents"
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 brla-gov/baton-rouge-fire-incidents-dakq-4sda 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 brla-gov/baton-rouge-fire-incidents-dakq-4sda: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 brla-gov/baton-rouge-fire-incidents-dakq-4sda

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 brla-gov/baton-rouge-fire-incidents-dakq-4sda:latest

This will download all the objects for the latest tag of brla-gov/baton-rouge-fire-incidents-dakq-4sda 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 brla-gov/baton-rouge-fire-incidents-dakq-4sda: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 brla-gov/baton-rouge-fire-incidents-dakq-4sda: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, brla-gov/baton-rouge-fire-incidents-dakq-4sda is just another Postgres schema.

Related Documentation:

Loading...