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 electric_vehicle_title_and_registration_activity
table in this repository, by referencing it like:
"wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd:latest"."electric_vehicle_title_and_registration_activity"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"vin_1_10", -- This represents the first 10 characters of each vehicle's Vehicle Identification Number (VIN).
"transaction_date", -- This is the month, day, and/or year the activity took place.
"transaction_year", -- This describes the 12 month period, beginning with January and ending with December, that the activity or status occurred within.
"vehicle_primary_use", -- This describes the intended use as defined by WAC 308-96A-099. This is sometimes referred to as ‘use class’.
"zip", -- This is the 5 digit number that the United States Postal Service (USPS) uses to route mail to the associated address.
"census_tract_2020", -- The Geographic Identifier (GEOID) is a combination of the state, county, and census tract codes as assigned by the United States Census Bureau in the 2020 census. This is also known as Census Tract. More information can be found here: https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_13 https://www.census.gov/programs-surveys/geography/guidance/geo-identifiers.html
"electric_utility", -- This is the electric power retail service territories serving the address of the registered vehicle. All ownership types for areas in Washington are included: federal, investor owned, municipal, political subdivision, and cooperative. If the address for the registered vehicle falls into an area with overlapping electric power retail service territories then a single pipe | delimits utilities of same TYPE and a double pipe || delimits utilities of different types. We combined vehicle address and Homeland Infrastructure Foundation Level Database (HIFLD) (https://gii.dhs.gov/HIFLD) Retail_Service_Territories feature layer using a geographic information system to assign values for this field. Blanks occur for vehicles with addresses outside of Washington or for addresses falling into areas in Washington not containing a mapped electric power retail service territory in the source data.
"electric_range", -- This tells how far a vehicle can travel purely on its electric charge.
"make", -- This is the manufacturer of the vehicle as determined by decoding the Vehicle Identification Number (VIN).
"model_year", -- This is the model year of the vehicle as determined by decoding the Vehicle Identification Number (VIN).
"_2019_hb_2042_battery_range_requirement", -- This field displays ‘Meets battery range requirement’ if the vehicle model can travel 30 miles or more solely on electricity. Otherwise, it will display the reason why the requirement is not met.
"meets_2019_hb_2042_electric_range_requirement", -- This shows if the vehicle meets the electric range requirement authorized by House Bill (HB) 2042 during the 2019 Legislative Session. This field displays 'True' if the vehicle model can travel 30 miles or more solely on electricity. Otherwise, 'False' will be displayed.
"_2019_hb_2042_sale_price_value_requirement", -- This field displays ‘Meets title transaction requirement’ when the vehicle sale price/value was $45,000 or less for new vehicles, or $30,000 or less for used vehicles. Otherwise, it will display the reason why the requirement is not met.
"_2019_hb_2042_purchase_date_requirement", -- This field displays ‘Meets purchase date requirement’ for title transactions for vehicles sold on or after August 1, 2019. Otherwise, it will display the reason why the requirement is not met.
"hybrid_vehicle_electrification_fee_paid", -- This fee is charged when qualifying vehicles renew registration. This indicates if it was collected during the transaction.
"electric_vehicle_fee_paid", -- This fee is charged when qualifying vehicles renew registration. This indicates if it was collected during the transaction.
"dol_vehicle_id", -- This is a unique identification number for each vehicle present in this dataset.
"transportation_electrification_fee_paid", -- This fee is charged when qualifying vehicles renew registration. This indicates if it was collected during the transaction.
"meets_2019_hb_2042_sale_date_requirement", -- This shows if the vehicle meets the sale date requirement authorized by House Bill (HB) 2042 during the 2019 Legislative Session. The field displays 'True' if the vehicle was sold on or after August 1, 2019. Otherwise, 'False' will be displayed.
"meets_2019_hb_2042_sale_price_value_requirement", -- This shows if the vehicle meets the sale price/value requirement authorized by House Bill (HB) 2042 during the 2019 Legislative Session. The field displays 'True' if the vehicle sale price/value was $45,000 or less for new vehicles, or $30,000 or less for used vehicles. Otherwise, 'False' will be displayed.
"city", -- This is the city in which the registered owner resides. Vehicles registered in Washington state may be located in other states.
"transaction_type", -- This is the category of activity that was performed as defined by Department of Licensing.
"base_msrp", -- This is the lowest Manufacturer's Suggested Retail Price (MSRP) for any trim level of the model in question.
"sale_price", -- This is the amount that was reported to have been paid for a vehicle. A value of zero indicates that the sale price was not available.
"new_or_used_vehicle", -- A vehicle is considered 'New' if it is being sold by the manufacturer to the first owner. Otherwise it is considered 'Used'.
"county", -- This is the geographic region of the state associated with the record. These addresses my be located in other states.
"date_of_vehicle_sale", -- This is the day on which the vehicle changed ownership.
"electric_vehicle_type", -- This distinguishes the vehicle as all electric, plug-in hybrid, or compressed natural gas.
"hb_2042_clean_alternative_fuel_vehicle_cafv_eligibility", -- This shows if vehicle title transactions were eligible for the sales tax exemption authorized by House Bill (HB) 2042 during the 2019 Legislative Session. If not eligible, reasons are provided.
"legislative_district", -- This is the specific section of Washington State that the vehicle's owner resides in, as represented in the state legislature.
"model", -- This is the model of the vehicle as determined by decoding the Vehicle Identification Number (VIN).
"odometer_code", -- This is the description of the odometer reading that was recorded at the time the transaction occurred. This value is associated with the 'Odometer Reading' field.
"odometer_reading", -- This is the odometer value provided by the vehicle owner at the time of the title transaction. You should consider the 'Odometer Reading Description' when reviewing this field.
"state_of_residence" -- This is the geographic region of the country associated with the record. These addresses may be located in other states.
FROM
"wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd:latest"."electric_vehicle_title_and_registration_activity"
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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd
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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd: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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd
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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd:latest
This will download all the objects for the latest
tag of wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd
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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd: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 wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd: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, wa-gov/electric-vehicle-title-and-registration-activity-rpr4-cgyd
is just another Postgres schema.