cambridgema-gov/electrical-permits-hvtc-3ab9
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 electrical_permits table in this repository, by referencing it like:

"cambridgema-gov/electrical-permits-hvtc-3ab9:latest"."electrical_permits"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "building_use",
    "estimated_value", -- Estimated Value of Electrical Work ($)
    "commercial_suites_low_voltage", -- Count of Commercial Suites  (Low Voltage Control Wiring)
    "receptacle_outlets_30_amps", -- Count of Receptacle Outlets (30 Amps)
    "kva", -- UPS Total KVA
    "floor_heat", -- Count of Rooms of Floor Heat
    "photovoltaic_panels", -- Count of Photovoltaic panels
    "bathroom_fans", -- Count of Residential Bathroom Fans
    "latitude",
    "insurance_coverage_type", -- Insurance Coverage Type
    "volts_existing_service",
    "volts_new_service",
    "amps_new_service",
    "start_date", -- Start Date of Work
    "ceiling_suspended_paddle", -- Count of Ceiling-Suspended (Paddle) Fans
    "heat_pump_tons", -- Heat Pump - Tons
    "fire_alarm_systems", -- Count of Fire Alarm Systems
    "ductless_a_c_units", -- Count of Ductless A/C Units
    "temporary_service",
    "count_of_meters_existing",
    "recessed_luminaries", -- Count of Recessed Luminaries
    "oil_burners", -- Count of Oil Burners
    "gas_burners", -- Count of Gas burners
    "heat_pumps", -- Count of Heat Pumps
    "commercial_exhaust_fans", -- Count of Commercial Exhaust Fans
    "suites_of_cubicle_wiring", -- Count of Suites of Cubicle Wiring
    "commercial_suites_data_wiring", -- Count of Commercial Suites (data wiring and/or telecom)
    "building_permit", -- Is this permit in conjunction with a building permit?
    "status", -- Permit Application Status
    "longitude",
    "address", -- Address where electrical work is being done
    "underground_existing",
    "overhead_new_service", -- New Serv:Overhead
    "volts_temporary_service",
    "amps_temporary_service",
    "permit_type",
    "licensee",
    "generators", -- Count of Generators
    "issue_date", -- Date when permit was issued
    "utility_authorization_number",
    "demo_make_safe",
    "receptacle_outlets_70_amps", -- Count of Receptacle Outlets (70 Amps)
    "total_ac_tonnage", -- Total AC Tonnage
    "emergency_lighting_battery", -- Count of Emergency Lighting Battery Units
    "application_submit_date", -- Date when application was submitted
    "receptacle_outlets_20_amps", -- Count of Receptacle Outlets (20 Amps)
    "garage_door_openers", -- Count of Garage Door Openers
    "exit_signs", -- Count of Exit Signs
    "receptacle_outlets_50_amps", -- Count of Receptacle Outlets (50 Amps)
    "waste_disposals", -- Count of Waste Disposals
    "receptacle_outlets_15_amps", -- Count of Receptacle Outlets (15 Amps)
    "description", -- Please Specify
    "ac_units_up_to_25_tons", -- Count of AC Units up to 25 Tons
    "gas_piping", -- Grounding of Gas Piping
    "ac_units_over_25_tons", -- Count of AC Units Over 25 Tons
    "vehicle_charging_stations", -- Count of Vehicle Charging Stations
    "siding",
    "dishwashers", -- Count of Dishwashers
    "count_of_meters_new_service",
    "heat_pump_kw", -- Heat Pump - KW
    "heating_appliances", -- Count of Heating Appliances
    "dryers", -- Count of Dryers
    "water_heaters", -- Count of Water Heaters
    "alerting_devices", -- Count of Alerting Devices
    "self_contained_detection", -- Count of Self-Contained Detection/Sounding Devices
    "firm_name",
    "id", -- Permit ID
    "central_vacuum_systems", -- Count of Central Vacuum Systems
    "swimming_pool",
    "ampacity", -- Total Ampacity of Panel/Feeders
    "seasonal_lighting",
    "temporary_lighting",
    "ranges", -- Count of Ranges
    "hot_tubs", -- Count of Hot Tubs
    "service_shutdown",
    "luminaires", -- Count of Luminaires
    "existing_service",
    "luminare_outlets", -- Count of Luminare Outlets
    "meters_temporary_service", -- Count of Meters (Temporary Service)
    "overhead_existing", -- Existing:Overhead
    "underground_temporary",
    "lightning_rod_system",
    "air_handling_units_duct_coils", -- Count of Air Handling Units Duct Coils
    "detection_and_initiating", -- Count of Detection and Initiating Devices
    "hydromassage_bathtubs", -- Count of Hydromassage Bathtubs
    "central_air_units", -- Count of Central Air Units
    "underground_new_service",
    "residential_units_data_wiring", -- Count of Residential Units (data wiring and/or telecom)
    "switches", -- Count of Switches
    "overhead_temporary", -- Temporar:Overhead
    "amps_existing_service",
    "intercom_sytems", -- Count of Intercom Sytems
    "ballasts", -- Count of Ballasts
    "residential_units_low_voltage", -- Count of Residential Units (Low Voltage Control Wiring)
    "new_service"
FROM
    "cambridgema-gov/electrical-permits-hvtc-3ab9:latest"."electrical_permits"
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 cambridgema-gov/electrical-permits-hvtc-3ab9 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 cambridgema-gov/electrical-permits-hvtc-3ab9: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 cambridgema-gov/electrical-permits-hvtc-3ab9

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 cambridgema-gov/electrical-permits-hvtc-3ab9:latest

This will download all the objects for the latest tag of cambridgema-gov/electrical-permits-hvtc-3ab9 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 cambridgema-gov/electrical-permits-hvtc-3ab9: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 cambridgema-gov/electrical-permits-hvtc-3ab9: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, cambridgema-gov/electrical-permits-hvtc-3ab9 is just another Postgres schema.

Related Documentation:

Loading...