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 energy_star_certified_residential_electric_cooking
table in this repository, by referencing it like:
"energystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33:latest"."energy_star_certified_residential_electric_cooking"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"product_type", -- Designates whether the product is considered a cooktop or a range.
"additional_model_information", -- This column includes for the qualified model or family, family members, additional model names, model numbers and other identifying information associated with a product or family/series of products for sales and marketing purposes. Other identifying information includes, but is not limited to, SKUs, retail numbers, and/or descriptions of models included/not included in the reported Model Family.
"upc", -- UPC codes provided by partners for ENERGY STAR certified products. The brand, model name and model number continue to serve as the identifiers used to establish certification. The UPC code data below is intended to aid in identification of ENERGY STAR models. UPC code data is not provided for all certified models.
"height_inches", -- The product height (inches) excluding the handles or knobs.
"cooking_zone_6_wattage_watts", -- The wattage of the sixth cooking zone.
"depth_inches", -- The product depth (inches) excluding the handles or knobs.
"model_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"additional_product_features", -- Indicates additional product features of the cooking top such as sensors, indicator lights, control locks, or active cooling.
"cooking_zone_1_wattage_watts", -- The wattage of the first cooking zone.
"width_inches", -- The product width (inches) excluding the handles or knobs.
"low_power_mode_energy_consumption_oven_kwh_yr", -- The annual combined low-power mode energy consumption of the conventional electric oven component of a combined electric cooking product, ETLP,O (kWh/year) based on measured test data.
"specialty_zones", -- Indicates available specialty zones on the cooking top, such as, simmering zone, warming zone, melting zone, griddle zone, power heating zone, concentric cooking zones, bridge element, and others.
"cooking_zone_3_size_inches", -- The maximum size of the third cooking zone.
"markets", -- Includes products sold in the U.S. and/or Canada and other ENERGY STAR partner countries.
"cooking_zone_3_wattage_watts", -- The wattage of the third cooking zone.
"installation_type", -- Designates whether the product is portable, built-in or slide-in, or freestanding.
"cooking_zone_5_wattage_watts", -- The wattage of the fifth cooking zone.
"smart_capabilities", -- Indicates if the cooking top has smart capabilities allowing it to connect to other devices or networks via different wireless protocols.
"date_available_on_market", -- The date that the model is available for purchase.
"cooking_zone_1_size_inches", -- The maximum size of the first cooking zone.
"cooking_zone_6_size_inches", -- The maximum size of the sixth cooking zone.
"cooking_top_technology", -- Designates whether the cooktop technology is induction, radiant, coil, or something else.
"amperage_amps",
"voltage_volts",
"energy_star_partner", -- An organization that signed a Partnership Agreement with EPA to manufacture or private label ENERGY STAR qualified products.
"cooking_zone_5_size_inches", -- The maximum size of the fifth cooking zone.
"model_number", -- A distinguishing, alphanumeric identifier, assigned to a product by the manufacturer or private labeler. The model number may include a wildcard that can be replaced by any letter or digit and still accurately capture what is covered by the model’s ENERGY STAR certification; an asterisk symbol (*) represents a letter, and a number symbol (#) a digit.
"annual_energy_consumption_kwh_yr", -- The rated/reported Annual Energy Consumption. This is the estimated annual energy use of the cooking top under typical conditions, including the active mode and the energy used by the cooking top while in low-power mode. It is based on an annual usage of 418 cooking events (averaging 31 minutes each) per year, or around 8 per week, as referenced by the U.S. Department of Energy test procedure, Code of Federal Regulations, Title 10, Section 430, Subpart B, Appendix I1. Actual energy consumption will vary depending on your usage patterns, including how often you use the cooking top.
"cooking_zone_2_size_inches", -- The maximum size of the second cooking zone.
"control_type", -- Indicates the control interface type for turning on/off cooking top. May include digital, knobs, or touch controls.
"number_of_cooking_zones", -- Indicates the number of cooking zones available.
"pd_id", -- The ENERGY STAR Unique ID (ESUID) is a string of seven numbers EPA assigns to an ENERGY STAR model or set of models with unique performance characteristics. This ESUID is unique to both the model and product specification version and is assigned by EPA upon receipt of certification information from the certification body. Each row within the product list will have a unique ESUID. Developers may wish to use this ESUID to track information on certified models in their information systems.
"brand_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"date_certified", -- The date on which the product was confirmed to meet the ENERGY STAR specification.
"low_power_mode_energy_consumption_cooking_top_kwh_yr", -- The annual combined low-power mode energy consumption for the cooking top ETLP (kWh/year) based on measured test data.
"average_cooking_zone_time_minutes", -- Average heat up time to 90C of all cooking zones.
"cooking_zone_4_size_inches", -- The maximum size of the fourth cooking zone.
"cooking_zone_4_wattage_watts", -- The wattage of the fourth cooking zone.
"energy_star_model_identifier", -- A unique string of characters assigned by certification bodies (CBs) to identify a model or set of models with the same performance characteristics. This identifier should remain the same for a model even if it is recertified to a new version of an ENERGY STAR specification. This string of characters is determined by CBs and is not the ENERGY STAR Unique ID assigned by EPA.
"cooking_zone_2_wattage_watts" -- The wattage of the second cooking zone.
FROM
"energystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33:latest"."energy_star_certified_residential_electric_cooking"
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 energystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.energystar.gov. When you queryenergystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33:latest
on the DDN, we "mount" the repository using the socrata
mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).
We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT
is only guaranteed for subsequent queries that land on the same node.
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 (like this repository), 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, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr clone
and sgr checkout
.
Mounting Data
This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.energystar.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone
to get the data. Instead, you can use the socrata
adapter with the sgr mount
command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.
First, install Splitgraph if you haven't already.
Mount the table with sgr mount
sgr mount socrata \
"energystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33" \
--handler-options '{
"domain": "data.energystar.gov",
"tables": {
"energy_star_certified_residential_electric_cooking": "m6gi-ng33"
}
}'
That's it! Now you can query the data in the mounted table like any other Postgres table.
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, energystar-gov/energy-star-certified-residential-electric-cooking-m6gi-ng33
is just another Postgres schema.