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 city_senior_center_interval_energy_data
table in this repository, by referencing it like:
"cambridgema-gov/city-senior-center-interval-energy-data-uuej-6t9x:latest"."city_senior_center_interval_energy_data"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"time_15_10",
"time_15_15",
"time_15_20",
"time_15_45",
"time_15_55",
"time_16_00",
"time_16_10",
"time_16_15",
"time_16_20",
"time_16_30",
"time_16_35",
"time_16_55",
"time_17_00",
"time_17_05",
"time_17_10",
"time_17_15",
"time_17_25",
"time_17_35",
"time_17_40",
"time_17_45",
"time_17_50",
"time_18_00",
"time_18_05",
"time_18_10",
"time_18_15",
"time_18_20",
"time_18_35",
"time_18_40",
"time_18_45",
"time_18_55",
"time_19_00",
"time_19_05",
"time_19_10",
"time_19_15",
"time_19_20",
"time_19_25",
"time_19_30",
"time_19_35",
"time_19_40",
"time_19_45",
"time_19_55",
"time_20_10",
"time_20_20",
"time_20_25",
"time_20_30",
"time_20_35",
"time_20_40",
"time_20_45",
"time_20_50",
"time_20_55",
"time_21_00",
"time_21_05",
"time_21_10",
"time_21_15",
"time_21_20",
"time_15_25",
"time_23_40", -- Data is measured in 5-minute time intervals
"time_23_25", -- Data is measured in 5-minute time intervals
"time_23_15",
"time_23_10",
"time_23_05",
"time_23_00",
"time_22_55",
"time_22_45",
"time_22_40",
"time_22_35",
"time_22_30",
"time_22_25",
"time_22_20",
"time_22_15",
"time_22_05",
"time_22_00",
"time_21_55",
"time_21_50",
"time_21_45",
"time_21_35",
"time_21_30",
"time_11_10",
"time_11_15",
"time_11_25",
"time_11_35",
"time_11_40",
"time_11_50",
"time_11_55",
"time_12_00",
"time_12_15",
"time_12_20",
"time_12_25",
"time_12_30",
"time_12_40",
"time_12_45",
"time_12_50",
"time_13_05",
"time_13_10",
"time_13_20",
"time_13_25",
"time_13_30",
"time_13_40",
"time_13_45",
"time_13_55",
"time_14_00",
"time_14_05",
"time_14_10",
"time_14_15",
"time_14_20",
"time_14_30",
"time_14_35",
"time_14_40",
"time_14_45",
"time_14_50",
"time_15_30",
"time_16_40",
"time_16_25",
"time_12_10",
"time_12_35",
"time_13_35",
"time_20_05",
"time_21_25",
"time_21_40",
"time_17_20",
"time_17_30",
"time_23_35", -- Data is measured in 5-minute time intervals
"time_22_50",
"time_22_10",
"time_23_30", -- Data is measured in 5-minute time intervals
"time_6_35", -- Data is measured in 5-minute time intervals
"time_4_30", -- Data is measured in 5-minute time intervals
"time_4_00", -- Data is measured in 5-minute time intervals
"time_15_35",
"time_10_30",
"time_10_55",
"time_11_30",
"time_11_45",
"time_7_25",
"time_14_55",
"time_16_50",
"time_15_00",
"time_16_45",
"time_16_05",
"time_12_55",
"time_13_00",
"time_20_15",
"time_20_00",
"time_19_50",
"time_17_55",
"time_18_50",
"time_18_30",
"time_2_45", -- Data is measured in 5-minute time intervals
"time_0_35", -- Data is measured in 5-minute time intervals
"time_1_00", -- Data is measured in 5-minute time intervals
"time_1_30", -- Data is measured in 5-minute time intervals
"time_0_25", -- Data is measured in 5-minute time intervals
"time_4_45", -- Data is measured in 5-minute time intervals
"time_1_20", -- Data is measured in 5-minute time intervals
"time_5_20", -- Data is measured in 5-minute time intervals
"time_1_25", -- Data is measured in 5-minute time intervals
"time_5_10", -- Data is measured in 5-minute time intervals
"time_3_50", -- Data is measured in 5-minute time intervals
"time_4_25", -- Data is measured in 5-minute time intervals
"time_24_00", -- Data is measured in 5-minute time intervals
"time_2_55", -- Data is measured in 5-minute time intervals
"time_3_40", -- Data is measured in 5-minute time intervals
"time_1_40", -- Data is measured in 5-minute time intervals
"time_5_00", -- Data is measured in 5-minute time intervals
"time_1_15", -- Data is measured in 5-minute time intervals
"time_23_55", -- Data is measured in 5-minute time intervals
"time_3_05", -- Data is measured in 5-minute time intervals
"time_6_50", -- Data is measured in 5-minute time intervals
"time_0_05", -- Data is measured in 5-minute time intervals
"time_6_10", -- Data is measured in 5-minute time intervals
"time_0_40", -- Data is measured in 5-minute time intervals
"time_0_30", -- Data is measured in 5-minute time intervals
"time_5_55", -- Data is measured in 5-minute time intervals
"time_6_00", -- Data is measured in 5-minute time intervals
"time_6_15", -- Data is measured in 5-minute time intervals
"time_6_20", -- Data is measured in 5-minute time intervals
"time_6_30", -- Data is measured in 5-minute time intervals
"time_6_40", -- Data is measured in 5-minute time intervals
"time_6_45", -- Data is measured in 5-minute time intervals
"time_6_55", -- Data is measured in 5-minute time intervals
"time_7_00", -- Data is measured in 5-minute time intervals
"time_7_15", -- Data is measured in 5-minute time intervals
"time_7_20",
"time_7_30",
"time_7_35",
"time_7_40",
"time_7_45",
"time_7_50",
"time_7_55",
"time_8_00",
"time_8_10",
"time_8_15",
"time_8_20",
"time_8_25",
"time_8_30",
"time_8_35",
"time_8_40",
"time_8_45",
"time_8_50",
"time_8_55",
"time_9_00",
"time_9_05",
"time_9_10",
"time_9_15",
"time_9_20",
"time_9_25",
"time_9_30",
"time_9_35",
"time_9_45",
"time_9_50",
"time_9_55",
"time_10_00",
"time_10_05",
"time_10_10",
"time_10_15",
"time_10_20",
"time_10_25",
"time_10_35",
"time_10_40",
"time_10_45",
"time_10_50",
"time_11_00",
"time_11_05",
"time_4_20", -- Data is measured in 5-minute time intervals
"time_2_05", -- Data is measured in 5-minute time intervals
"account", -- Utility Account Number
"time_0_45", -- Data is measured in 5-minute time intervals
"time_0_50", -- Data is measured in 5-minute time intervals
"time_1_55", -- Data is measured in 5-minute time intervals
"time_2_15", -- Data is measured in 5-minute time intervals
"time_3_15", -- Data is measured in 5-minute time intervals
"time_5_05", -- Data is measured in 5-minute time intervals
"time_5_15", -- Data is measured in 5-minute time intervals
"time_6_05", -- Data is measured in 5-minute time intervals
"time_6_25", -- Data is measured in 5-minute time intervals
"time_5_40", -- Data is measured in 5-minute time intervals
"measure", -- Electricity Use or Electricity Demand. Electricity use is the amount of electricity that has been consumed over a certain period of time. Electricity demand is the maximum amount of electrical energy that is being consumed at a given time.
"time_15_05",
"time_8_05",
"time_9_40",
"time_3_30", -- Data is measured in 5-minute time intervals
"time_5_45", -- Data is measured in 5-minute time intervals
"time_0_20", -- Data is measured in 5-minute time intervals
"units", -- Units measuring electricity use or electricity demand. Electricity use is measured in kilowatt hours (kWh). Electricity demand is measured in kilowatts (kW). Additionally, this dataset contains measurements for Power Factor and Reactive Power. Power Factor is the ratio of the real power that is flowing to the load and the apparent power that is supplied to the circuit. Reactive Power occurs in alternating current circuits when there is a phase difference between voltage and current. It is measured in kVAR for demand and kVARh for use.
"time_23_20",
"time_18_25",
"time_13_50",
"time_14_25",
"time_12_05",
"time_13_15",
"time_15_40",
"time_15_50",
"time_7_05", -- Data is measured in 5-minute time intervals
"time_7_10", -- Data is measured in 5-minute time intervals
"time_11_20",
"time_3_45", -- Data is measured in 5-minute time intervals
"time_3_55", -- Data is measured in 5-minute time intervals
"time_4_55", -- Data is measured in 5-minute time intervals
"time_2_35", -- Data is measured in 5-minute time intervals
"date", -- Date of measurment
"channel", -- Information that is available from a Utility Meter. For Electricity Use: Power Factor, Reactive Power and Electricity Use. For Electricity Demand: Demand, Power Factor and Reactive Power
"time_0_10", -- Data is measured in 5-minute time intervals
"time_0_15", -- Data is measured in 5-minute time intervals
"time_0_55", -- Data is measured in 5-minute time intervals
"time_1_05", -- Data is measured in 5-minute time intervals
"time_1_10", -- Data is measured in 5-minute time intervals
"time_1_35", -- Data is measured in 5-minute time intervals
"time_1_45", -- Data is measured in 5-minute time intervals
"time_1_50", -- Data is measured in 5-minute time intervals
"time_2_00", -- Data is measured in 5-minute time intervals
"time_2_10", -- Data is measured in 5-minute time intervals
"time_2_20", -- Data is measured in 5-minute time intervals
"time_2_25", -- Data is measured in 5-minute time intervals
"time_2_30", -- Data is measured in 5-minute time intervals
"time_2_40", -- Data is measured in 5-minute time intervals
"time_2_50", -- Data is measured in 5-minute time intervals
"time_3_00", -- Data is measured in 5-minute time intervals
"time_3_10", -- Data is measured in 5-minute time intervals
"time_3_20", -- Data is measured in 5-minute time intervals
"time_3_25", -- Data is measured in 5-minute time intervals
"time_3_35", -- Data is measured in 5-minute time intervals
"time_4_05", -- Data is measured in 5-minute time intervals
"time_4_10", -- Data is measured in 5-minute time intervals
"time_4_15", -- Data is measured in 5-minute time intervals
"time_4_35", -- Data is measured in 5-minute time intervals
"time_4_40", -- Data is measured in 5-minute time intervals
"time_4_50", -- Data is measured in 5-minute time intervals
"time_5_25", -- Data is measured in 5-minute time intervals
"time_5_30", -- Data is measured in 5-minute time intervals
"time_5_35", -- Data is measured in 5-minute time intervals
"time_5_50", -- Data is measured in 5-minute time intervals
"time_23_50", -- Data is measured in 5-minute time intervals
"time_23_45" -- Data is measured in 5-minute time intervals
FROM
"cambridgema-gov/city-senior-center-interval-energy-data-uuej-6t9x:latest"."city_senior_center_interval_energy_data"
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/city-senior-center-interval-energy-data-uuej-6t9x
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 cambridgema-gov/city-senior-center-interval-energy-data-uuej-6t9x: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/city-senior-center-interval-energy-data-uuej-6t9x
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/city-senior-center-interval-energy-data-uuej-6t9x:latest
This will download all the objects for the latest
tag of cambridgema-gov/city-senior-center-interval-energy-data-uuej-6t9x
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/city-senior-center-interval-energy-data-uuej-6t9x: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/city-senior-center-interval-energy-data-uuej-6t9x: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/city-senior-center-interval-energy-data-uuej-6t9x
is just another Postgres schema.