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 i_can_help_with_supplies_during_coronavirus
table in this repository, by referencing it like:
"delaware-gov/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2:latest"."i_can_help_with_supplies_during_coronavirus"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"masks", -- Do you have face masks on hand?
"cleaning_large_quantity", -- Do you have access to a large quantity of cleaning supplies? (More than 100)
"tech_warehouse", -- Are you a technology warehouse?
"food_lic_restaurant", -- Are you a licensed restaurant?
"med_warehouse", -- Are you a warehouse?
"creationdate", -- create date on GIC daily report
"sam_num", -- SAM Number
"primary_contact_city", -- Primary Contact City
"cleaning_delivery_time_over", -- Delivery time more than 72 hours for cleaning supplies
"cleaning_quantity", -- If large quantity available how many
"cleaning_supplies_description", -- What cleaning supplies do you have on hand?
"delivery_time_over_72", -- More than 72 hours
"bus_lic_num", -- Business License Number
"primary_contact_email", -- Primary Contact Email
"primary_contact_phone", -- Primary Contact Phone
"fda_reg", -- Do you have an FDA registration?
"hair_covers", -- Do you have hair covers on hand?
"tech_supplier", -- Are you a technology supplier?
"ppe", -- Do you have Personal Protective Equipment (PPE) supplies?
"order_or_manucturer", -- Do you have capacity to order or manufacture supplies for future use?
"tech_vendor", -- Are you a technology vendor?
"clean_supplier", -- Are you a cleaning supplier?
"tech_delivery_time_over_72", -- Delivery time more than 72 hours for technology supplies
"food_delivery_time_over_72", -- More than 72 hours
"food_source_quantity", -- Please indicate your source and quantity of packaged food
"duns_num", -- Duns Num
"hotel_or_motel", -- Are you a hotel or motel resource?
"face_shields", -- Do you have face shields on hand?
"redistributed_immediately", -- Do you have supplies on hand that can be redistributed immediately?
"sod_contract", -- Do you have a current State of Delaware contract?
"agency_type", -- Agency Type
"use_third_party_vendors", -- Do you use third party vendors for purchases?
"n95_mask", -- Do you have N95 masks on hand?
"technology_type", -- What technology do you have on hand?
"food", -- Are you a food resource?
"safe_clean_rooms", -- Ability to provide safe clean rooms
"medical_equipment", -- Do you have medical equipment?
"universal_ppe_supplies", -- Do you have Universal Precaution or Personal Protective Equipment supplies?
"respirators", -- Do you have respirators on hand?
"oxygen_tanks", -- Do you have oxygen tanks on hand?
"delivery_time", -- How long will it take to get the supplies to the designated location?
"med_supplier", -- Are you a supplier?
"large_quantity", -- Do you have access to a large quantity of supplies? (More than 100)
"catheters", -- Do you have catheters on hand?
"cleaning_delivery_time", -- How long will it take to get the supplies to the designated location?
"tech_secure_install", -- Can you install that technology with up to date industry security?
"number_rooms", -- Number of rooms are in hotel or motel
"technology", -- Are you a technology resource?
"food_delivery_time", -- How quickly can you deliver your food to an identified in-state source?
"medical_supplies_quantity", -- How many of each do you have?
"technology_large_quantity", -- Do you have access to a large quantity of technology supplies?
"sanitizer", -- Do you have hand sanitizer?
"gloves", -- Do you have gloves on hand?
"cleaning", -- Are you a cleaning resource?
"niosh_cert", -- Do you have a NIOSH Certificate?
"hotel_motel", -- Are you a hotel or motel?
"primary_contact_address", -- Primary Contact Address
"med_vendor", -- Are you a vendor?
"bus_name", -- Business Name
"technology_delivery_time", -- How long will it take to get the technology supplies to the designated location?
"goggles_glasses", -- Do you have goggles/glasses on hand?
"surgical_masks", -- Do you have surgical masks on hand?
"tubes", -- Do you have tubes on hand?
"resource_type", -- Resource Type
"gowns", -- Do you have gowns on hand?
"medical_supplies", -- Do you have medical supplies?
"food_wholesaler", -- Are you a licensed wholesaler?
"business_website", -- Business Website
"primary_contact_zip", -- Primary Contact Zip
"primary_contact_name", -- Primary Contact Name
"other_supplies", -- Do you have other supplies on hand?
"ce_prod", -- Do you have a CE Product Certificate?
"sod_contract_info", -- State of Delaware Contract Number and Division
"clean_warehouse", -- Are you a cleaning warehouse?
"homemade_mask", -- Do you have homemade masks on hand?
"clean_vendor", -- Are you a cleaning vendor?
"primary_contact_state", -- Primary Contact State
"prod_fda_reg", -- Are your products registered with the FDA?
"pay_terms", -- Payment Terms
"food_supermarket" -- Are you a licensed supermarket?
FROM
"delaware-gov/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2:latest"."i_can_help_with_supplies_during_coronavirus"
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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2
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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2: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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2
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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2:latest
This will download all the objects for the latest
tag of delaware-gov/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2
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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2: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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2: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/i-can-help-with-supplies-during-coronavirus-c6zw-7xr2
is just another Postgres schema.