Query the Data Delivery Network
Query the DDNThe 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 issued_construction_permits
table in this repository, by referencing it like:
"datahub-austintexas-gov/issued-construction-permits-3syk-w9eu:latest"."issued_construction_permits"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"total_existing_bldg_sqft", -- Existing square footage of property before project
"applicant_address2", -- Applicant address line 2
"applicant_address1", -- Applicant address line 1
"applicant_phone", -- Applicant phone
"applicant_org", -- Organization the applicant is associated with.
"contractor_zip", -- Contractor zip
"contractor_city", -- Contractor city
"contractor_address2", -- Contractor street address line 2
"contractor_address1", -- Contractor street address line 1
"contractor_company_name", -- Company name of the primary contractor associated with the permit.
"location", -- The geographic coordinates for the project which are comprised of both latitude and longitude
"longitude", -- Coordinate that specifies the east - west position of a point on the surface of the Earth
"original_state", -- State of the property assoicated with the permit
"link", -- Web link that show details of project inside AB+C
"expiresdate", -- Date on which the permit will/would have expire(d)
"location_address",
"location_zip",
":@computed_region_8spj_utxs",
"statusdate", -- Indicates the last time the status or ExpiresDate of a permit was updated in the AMANDA database.
":@computed_region_q9nd_rr82",
":@computed_region_e9j2_6w3z",
"fiscal_year_issued", -- Fiscal Year corresponding to when the permit was issued
":@computed_region_m2th_e4b7",
"calendar_year_issued", -- Calendar Year corresponding to when the Permit was issued
":@computed_region_rxpj_nzrk",
":@computed_region_a3it_2a2z",
"issue_date", -- Date on which the permit was issued
":@computed_region_qwte_z96m",
":@computed_region_i2aj_cj5t",
":@computed_region_xzeg_zdjk",
":@computed_region_6gig_z43c", -- This column was automatically created in order to record in what polygon from the dataset 'Council Districts Fill - TESTING DO NOT USE (Adrianne)' (6gig-z43c) the point in column 'location' is located. This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
"permit_location", -- Property street address as a means to help identify project.
"condominium", -- Is this property a condominium?
"location_state",
"location_city",
"permit_type_desc", -- Description of the Permit Type
"permit_class", -- Sub Type of the permit
"issued_in_last_30_days", -- Yes/No value to indicate if the permit was issued in the last 30 days. This field is evaluated using the last date that the data was refreshed.
"total_new_add_sqft", -- Additional square footage gained from work being done.
"applicant_city", -- Applicant city
"electrical_valuation_remodel", -- Valuation of electrical remodel work
"certificate_of_occupancy", -- Yes or No field to specify if the Certificate of Occupancy was required for this permit. This information applies only to Building Permits.
"description", -- Detailed description of work permitted
"applicantzip", -- Applicant zip code
"permittype", -- Raw values indicating type of permit in abbreviated format
"legal_description", -- Legal Description of the property associated with the permit.
"medgas_valuation",
"contractor_trade", -- Indicates contractor trade.
"applicant_full_name", -- Full name of the applicant
"applieddate", -- Date on which the permit was applied. This relates to the original Plan Review application submission where applicable.
"status_current", -- Current status of permit
"building_valuation", -- Valuation of building where project is occurring
"council_district", -- Council District associated with the permit property location
"contractor_phone", -- Contractor phone number
"project_id", -- ID associated with the permit within the database. Also referred to as the FolderRSN.
"contractor_full_name", -- Full name of the contractor
"total_lot_sq_ft", -- The total square footage attributed to the lot size.
"permit_class_mapped", -- Indicates if the permit is intended for Residential or Commercial. This mapping is derived from the PermitClass field (if the Class starts with "R", it is residential, otherwise it is commercial)
"jurisdiction", -- Jurisdiction of permit property
"electrical_valuation",
"day_issued", -- Day of the week the permit was issued
"original_zip", -- Zip code of the property associated with the permit
"building_valuation_remodel", -- Valuation of remodel for project
"permit_number", -- Permit number
"work_class", -- Work type of the permit
"number_of_floors", -- How many floors property has
"issue_method", -- Permit issuance method. "Permit Center" represents any permit which a permit center technician manually issued (e.g., will include fax based requests). "Online" includes permits issued through the website including Austin Build and Connect or Customer Self Assignment.
"tcad_id", -- TCAD_ID aligns with the Geographic ID field on the TravisCAD.org website when performing a property search.
"latitude", -- Coordinate that specifies the north - south position of a point on the surface of the Earth
"masterpermitnum", -- If the permit is listed as the child of another permit, this is the Project ID of that parent permit. A building permit's (BP) master permit number will reference the Plan Review Project ID, while trades under that BP will reference the BP's ID as their master. This may also be called the "parent folderRSN".
"original_city", -- City of the property associated with the permit
"original_address1", -- Property address associated with the permit
"medgas_valuation_remodel", -- Valuation of medgas remodel work
"plumbing_valuation_remodel", -- Valuation of plumbing remodel work
"plumbing_valuation",
"mechanical_valuation_remodel", -- Valuation of mechanical remodel work
"mechanical_valuation",
"housing_units", -- Number of household units for a given building
"total_job_valuation", -- Total dollar valuation for entire job for each building permit (e.g. will include Building, Electrical, Mechanical, and Plumbing valuations, but not other Building Permits in the same project)
"total_valuation_remodel", -- Total dollar valuation for remodeling aspects of the job
"remodel_repair_sqft", -- Square footage of project affected by work being done.
"completed_date" -- Date on which the permit was completed
FROM
"datahub-austintexas-gov/issued-construction-permits-3syk-w9eu:latest"."issued_construction_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 datahub-austintexas-gov/issued-construction-permits-3syk-w9eu
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because datahub-austintexas-gov/issued-construction-permits-3syk-w9eu: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 datahub-austintexas-gov/issued-construction-permits-3syk-w9eu
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 datahub-austintexas-gov/issued-construction-permits-3syk-w9eu:latest
This will download all the objects for the latest
tag of datahub-austintexas-gov/issued-construction-permits-3syk-w9eu
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 datahub-austintexas-gov/issued-construction-permits-3syk-w9eu: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 datahub-austintexas-gov/issued-construction-permits-3syk-w9eu: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, datahub-austintexas-gov/issued-construction-permits-3syk-w9eu
is just another Postgres schema.