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 well_permits
table in this repository, by referencing it like:
"delaware-gov/well-permits-2655-qn8j:latest"."well_permits"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"proposeddrillmethod", -- Proposed method of drilling to create the well. (See attached data dictionary for valid values)
"innercasingtop", -- Feet above or below ground surface of the top of the inner casing material.
"estdailyuse", -- Estimated daily use of water from the well measured in gallons per day.
"wellcomments", -- General comments on this record generated during processing and review.
"sampled", -- Has well been sampled? (Yes/No)
"allocreview", -- Does well require a water allocation review? (Required for greater than 50,000 gallons per day) (Yes/No)
"longitude", -- Longitude of well location in Decimal Degrees (WGS 84).
"x", -- Easting (X) map coordinate of well location, in Delaware State Plane Coordinate NAD 1983 Meters.
"welltermunusinches", -- Measurement, in inches, of the top of the well, whether above (+) or below (-) grade.
"wellstatus", -- Status of well permit application. (See attached data dictionary for valid values)
"pciv", -- Are there potential sources of contamination in the vicinity (1,000 feet of the well location)? (Yes/No)
"potable", -- Is the intended use for the water from this well for potable consumption? (Yes/No)
"reviewable", -- Does the well permit require additional review? (Yes/No)
"basin", -- Major Drainage basin in which well is located (e.g. Delaware River, Chesapeake Bay, Atlantic Ocean) (See attached data dictionary for valid values)
"requiresallocpermit", -- Does the well require a water allocation permit? (Yes/No)
"cpcn", -- Is property covered by a Certificate of Public Convenience and Necessity (CPCN) issued by the Public Services Commission? (Yes/No)
"injection", -- Is property covered by a Certificate of Public Convenience and Necessity (CPCN) issued by the Public Services Commission? (Yes/No)
"geocoded_location", -- This is a system generated field created from the Latitude and Longitude fields so that the data can be mapped.
"smalllot", -- Is well on a small lot (<0.5 acres)? (Yes/No)
"wellabandonmentreason", -- Reason well was abandoned and sealed (e.g. no water, contamination, etc), if known.
"url_for_permit_details", -- Web page link to see more details about the specific well permit, including scanned documents, if available. [Note: per 29 Del. Code §10002 (l)(17)a.2., specific location information for the following well types has been redacted: Public-Standard, Public-Miscellaneous, Industrial, Fire Protection-Standard, Fire Protection-Public, and Aquifer Storage and Recovery (ASR).]
"totaldepthactual", -- Actual depth well drilled to, measured in feet below land surface.
"replacement", -- Is the well a replacement well? (Yes/No)
"minwelldiameter", -- Minimum diameter of well, in inches (for most well min and max are same)
"gravelmaterial", -- Material used to make up the filter pack. (See attached data dictionary for valid values)
"pumpmaker", -- Brand of pump to be used.
"totaldepthprop", -- Proposed total depth of well, measured in feet below land surface.
"groutbase", -- Feet below ground surface of the base of the material used to seal the annular space of the well. (The space between the well casing and the ground)
"confined", -- Is the well in a confined aquifer? (Yes/No)
"wellterminustype", -- Type of upper terminus unit used to connect well to water distribution system (See attached data dictionary for valid values)
"permitnumber", -- Unique identifier number of the well permit for this record and shown on well tag.
"localwellid", -- [Optional] Local identifier, or common name of the Well (eg. MW-1).
"estconstructdate", -- Estimated date of construction.
"completionreportdate", -- Date of completion report, if received.
"maxwelldiameter", -- Maximum diameter of well, in inches.
"pumptesttime", -- Hours that the well was tested.
"testtemp", -- Is well a temporary test well? (Yes/No)
"emergency", -- Was the well permit issued in response to an emergency situation? (Yes/No)
"gmz", -- Is well in an established Groundwater Management Zone (GMZ)? (Yes/No)
"reference_number", -- Reference number from DNREC's Online Permitting Application
"retainwell", -- Was this well replaced and retained for other uses. (Y or 1 = Yes. N or 0 = no)
"floodplain", -- Is well located in a floodplain? (Yes/No)
"watershed", -- Watershed in which well is located (See attached data dictionary for valid values)
"locationmethod", -- Method used to determine location of well specified in the X, Y, or Lat/Long fields (See attached data dictionary for valid values).
"latitude", -- Latitude of well location in Decimal Degrees (WGS 84).
"y", -- Northing (Y) map coordinate of well location, in Delaware State Plane Coordinate NAD 1983 Meters.
"wellauthcode", -- Authorization code for well-drilling activity to create the permitted well.
"wellcontractor", -- Name of contractor or business installing the well.
"replacedwellpermitnumber", -- If a replacement well, permit number of the well that was replaced, if known.
"staticwaterlevel", -- Water level when the well is not pumping, measured in feet below land surface.
"pumpingwaterlevel", -- Depth to maximum water level during pumping, measured in feet below land surface.
"pumptestrate", -- Tested capacity of pump, measured in gallons per minute.
"pumpintakesetting", -- Feet below land surface at which the well pump takes in water.
"graveltop", -- Feet below ground surface of the top of the gravel filter pack.
"grouttop", -- Inches below ground surface of the top of the material used to seal the annular space of the well. (The space between the well casing and the ground)
"innercasingbase", -- Feet below ground surface of the base of the inner casing material.
"screenmaterial", -- Material that the well screen is made of (PVC, Stainless Steel, etc) (See attached data dictionary for valid values)
"screentop", -- Feet below land surface of the top of the well screen.
"estmaxcapacity", -- Estimated maximum capacity of the well, measured in gallons per minute.
"permitapprovaldate", -- Date of permit approval.
"locreviewdate", -- Date that proposed location was reviewed for potential contaminants.
"apprecdate", -- Date well application was received by DNREC.
"owner", -- Owner of the well.
"welltype", -- Type of well permitted. (See attached data dictionary for valid values)
"wellpit", -- Is well terminus housed in a pit or vault? (Yes/No)
"gravelbase", -- Feet below ground surface of the bottom of the gravel filter pack.
"abandonreportdate", -- Date of well abandonment report for sealed wells, if received..
"existing", -- Is there an existing well on the property? (Yes/No)
"agprecdistrict", -- Is well in an Agricultural Preservation District? (Yes/No)
"county", -- County of well location (New Castle, Kent, Sussex)
"screenbase", -- Feet below land surface of the bottom of the well screen.
"proposedconstructionreviewdate", -- Date that the proposed construction specifications were reviewed.
"taxid", -- County tax parcel identification number for property on which the well is located. Example Parcel ID Format: New Castle: 07-008.00-033, Kent: MN-00-159.00-01-32.03.000, Sussex: 1-31-02.00-0039.01
"owneraddressfull", -- Full address of the owner of the well. Per 29 Del. Code, §10002 (l)(17)a.2., specific location information for the following well types has been redacted: Public-Standard, Public-Miscellaneous, Industrial, Fire Protection-Standard, Fire Protection-Public, and Aquifer Storage and Recovery (ASR).
"groutmaterial", -- Material used to seal the annular of the well. (The space between the well casing and the ground) (See attached data dictionary for valid values)
"licensenumber", -- License number of contractor or business installing the well.
"septicpermitnumber", -- Permit number of any septic system on the same property, if available.
"waterleveldate", -- Date on which water level was measured.
"pumpratedcapacity", -- Rated capacity of pump, measured in gallons per minute.
"innercasingmaterial" -- The material that makes up the inner casing.
FROM
"delaware-gov/well-permits-2655-qn8j:latest"."well_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 delaware-gov/well-permits-2655-qn8j
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 delaware-gov/well-permits-2655-qn8j: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 delaware-gov/well-permits-2655-qn8j
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 delaware-gov/well-permits-2655-qn8j:latest
This will download all the objects for the latest
tag of delaware-gov/well-permits-2655-qn8j
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 delaware-gov/well-permits-2655-qn8j: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 delaware-gov/well-permits-2655-qn8j: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, delaware-gov/well-permits-2655-qn8j
is just another Postgres schema.