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 alternative_fuels_and_electric_vehicle_charging
table in this repository, by referencing it like:
"colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz:latest"."alternative_fuels_and_electric_vehicle_charging"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"geolocation", -- The GeoLocation point
"facility_type", -- What type of facility is this station
"ev_connector_types", -- For electric stations, an array of strings identifying the connector types available at this station. Valid connector types are: NEMA515 = NEMA 5-15 (Level 1), NEMA520 = NEMA 5-20 (Level 1), NEMA1450 = NEMA 14-50 (Level 1), J1772 = J1772 (Level 2), CHADEMO = CHAdeMO (DC fast charging), J1772COMBO = SAE J1772 Combo (DC fast charging), TESLA = Tesla (DC fast charging and Level 2)
"open_date", -- The date that the station began offering the fuel. Please note that most LPG (propane) stations do not have open dates. Some open dates are approximate. Also note that electric station records that are imported to the Station Locator on a daily basis through a network API do not have open dates
"date_last_confirmed", -- The date the station's details were last confirmed
"geocode_status", -- A rating indicating the approximate accuracy of the latitude and longitude for the station's address, given as code values: GPS = The location is from a real GPS readout at the station. 200-9 = Premise (building name, property name, shopping center, etc.) level accuracy. 200-8 = Address level accuracy. 200-7 = Intersection level accuracy. 200-6 = Street level accuracy. 200-5 = ZIP code (postal code) level accuracy. 200-4 = Town (city, village) level accuracy. 200-3 = Sub-region (county, municipality, etc.) level accuracy. 200-2 = Region (state, province, prefecture, etc.) level accuracy. 200-1 = Country level accuracy. 200-0 = Unknown accuracy.
"ev_network_web", -- For electric stations, the EVSE network Web site, if applicable
"ev_network", -- For electric stations, the name of the EVSE network, if applicable
"ev_level2_evse_num", -- For electric stations, the number of Level 2 EVSE (J1772 connector)
"station_phone", -- The phone number of the station
"longitude", -- The longitude of the station's address
"city", -- The city of the station's location
"street_address", -- The street address of the station's location
"zip", -- The ZIP code (postal code) of the station's location
"updated_at", -- The time the station's details were last updated (ISO 8601 format)
"status_code", -- The current status of the station, given as code values: E = Open: The station is open. P = Planned: The station is not yet open, but plans to carry alternative fuel in the future, or the station is temporarily out of service. See the "Expected Date" field for an anticipated open date. T = Temporarily unavailable: The station is temporarily unavailable. See the “Expected Date” field for an anticipated open date
"state", -- The two character U.S. state code of the station's location
"owner_type_code", -- The type of organization that owns the fueling infrastructure. Owner types are given as code values: P = Privately owned, T = Utility owned, FG = Federal government owned, LG = Local government owned, SG = State government owned, J = Jointly owned (combination of owner types)
"ng_vehicle_class", -- For CNG and LNG stations, the maximum vehicle size that can physically access the fueling infrastructure, given as code values: LD =Station can only accommodate light-duty vehicles (Classes 1-2). MD = Station can accommodate light- and medium-duty vehicles (Classes 1-5). HD = Station can accommodate light-, medium-, and heavy-duty vehicles (Classes 1-8)
"ng_psi", -- For CNG stations, a space separated list of PSI pressures available
"ng_fill_type_code", -- For CNG stations, the type of dispensing capability available, given as code values: Q = Quick fill, T = Timed fill, B = Both: quick fill and timed fill
"lpg_primary", -- For propane stations, the type of station, given as a boolean: true = Primary: A propane station is considered primary because it meets the following criteria, developed based on feedback from the propane industry: The station is staffed and able to fuel vehicles during normal business hours (e.g., 8am-5pm M-F), and does not require drivers to call ahead; The station is equipped with a dedicated or purpose-built fuel dispenser for vehicle fueling; and The station accepts credit cards or fleet cards. false = Secondary: The station does not meet the criteria to be considered primary
"lpg_nozzle_types", -- Types of nozzles offered to LPG
"latitude", -- The latitude of the station's address
"intersection_directions", -- Brief additional information about how to locate the station
"groups_with_access_code_french", -- Access codes in french
"groups_with_access_code", -- A description of who is allowed to access the station and other station access information: Private = Private station. Private - fleet customers only = Private station that may allow other entities to fuel through a business-to-business arrangement. For more information, fleet customers should refer to the “Access Days Time” field for contact information or contact the station directly. Private – government only = Private station available only to government vehicles, or some subset of government vehicles. Public = Publicly available to all customers. Public – call ahead = Publicly available, but customers should call before visiting the station. See “Station Phone” for more details. Public – credit card at all times = Publicly available, but only accepts credit cards as payment. The station may also accept fleet cards or station-specific fueling cards. See “Cards Accepted” field for more details. Public – card key at all times = Publicly available, but only accepts fleet cards or station-specific fueling cards as payment. See “Cards Accepted” field for more details. Public – credit card after hours = Publicly available, and accepts credit cards 24 hours a day. See “Access Days Time” and “Cards Accepted” fields for more details. Public – card key after hours = Publicly available, and accepts fleet cards or station-specific fueling cards 24 hours a day. See “Access Days Time” and “Cards Accepted” fields for more details. PLANNED – not yet available = Not yet open, but plans to carry alternative fuel in the future. See the "Expected Date" field for an anticipated open date. TEMPORARILY UNAVAILBLE = Temporarily unavailable. See the “Expected Date” field for an anticipated open date
"ev_pricing", -- The price for electric vehicles
"ev_on_site_renewable_source", -- On-site renewable sources offered for electric vehicles
"ev_level1_evse_num", -- For electric stations, the number of Level 1 EVSE (standard 110V outlet)
"ev_dc_fast_count", -- For electric stations, the number of DC Fast Chargers
"e85_other_ethanol_blends", -- Various ethanol blends
"e85_blender_pump", -- For E85 stations, an indication of whether the station has a blender pump on site, given as a boolean: true = In addition to E85, the station has a blender pump capable of providing mid-level ethanol blends. False = The station does not have a blender pump
"country", -- Country of originn
"cng_vehicle_class", -- Vehicles classes with compressed natural gas
"cng_total_compression_capacity", -- The total compression capacity offered for CNG by station
"cng_storage_capacity", -- The storage capacity offered for CNG by station
"cng_psi", -- The psi of compressed natural gas per station
"cng_fill_type_code", -- Codes offered to compressed natural gas
"cng_dispenser_num", -- Number of CNG dispensers
"cards_accepted", -- A space-separated list of payment methods accepted. Payment methods are given as code values: A = American Express, D = Discover, M = MasterCard, V = VISA, Cash = Cash, Checks = Check, CFN = Commercial Fueling Network, CleanEnergy = Clean Energy, Comdata = Comdata, EFS = EFS, FleetOne = Fleet One, FuelMan = Fuelman, GasCard = GASCARD, PHH = PHH, PacificPride = Pacific Pride, Speedway = Speedway, Tchek = T-Chek T-Card, TCH = TCH, Trillium = Trillium, Voyager = Voyager, Wright_Exp = WEX
"bd_blends", -- For biodiesel stations, the level of biodiesel blends the station provides
"access_detail_code", -- Details for the required access code (credit cards, credit cards after hours)
"access_days_time", -- Hours of operation for the station
"access_code", -- Does the station have a required access code or is it open to the public
"maximumvehicleclass", -- The highest vehicle class offered
"lngstationsellsrenewablenatrualgas", -- For LNG stations, whether they sell renewable natural gas
"cngonsiterenewablesource", -- For CNG stations, do they provide renewable sources
"id", -- A unique identifier for this specific station
"station_name", -- The name of the station
"fuel_type_code", -- The type of alternative fuel the station provides. Fuel types are given as code values: BD = Biodiesel (B20 and above) CNG = Compressed Natural Gas, E85 = Ethanol (E85) ELEC = Electric, HY = Hydrogen, LNG = Liquefied Natural Gas, LPG = Liquefied Petroleum Gas (Propane)
"restrictedaccess", -- Does the station have restricted access or not
"lngvehicleclass", -- For LNG stations, the available/unique vehicle class offered.
"npsunitname", -- Unit names of national parks under the NPS
"cngstationsellsrenewablenatrualgas", -- For CNG stations, whether they sell renewable natural gas
"evworkplacecharging", -- For EV stations, whether they offer workplace charging stations
":@computed_region_nku6_53ud" -- This column was automatically created in order to record in what polygon from the dataset 'Counties' (nku6-53ud) the point in column 'geolocation' is located. This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
FROM
"colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz:latest"."alternative_fuels_and_electric_vehicle_charging"
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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz
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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz: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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz
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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz:latest
This will download all the objects for the latest
tag of colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz
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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz: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 colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz: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, colorado-gov/alternative-fuels-and-electric-vehicle-charging-team-3ugz
is just another Postgres schema.