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 vehicle_title_transactions_by_department_of
table in this repository, by referencing it like:
"wa-gov/vehicle-title-transactions-by-department-of-cdk6-5kdf:latest"."vehicle_title_transactions_by_department_of"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"electrification_level", -- Describes how effectively a vehicle uses electricity to power it. A Mild Hybrid electric vehicle uses an electric battery and electric motor to suppliment the power of an internal combustion engine (ICE) but cannot power the vehicle using electricity alone. The only energy source added externally for this type of vehicle is a petroleum product. A Strong Hybrid electric vehicle also uses an electric battery and electric motor to suppliment the power of an internal combustion engine (ICE). It can power the vehicle using electricity alone. The only energy source added externally for this type of vehicle is a petroleum product. A Plug-in Hybrid electric vehicle (PHEV) uses an electric battery and electric motor as an alternative power source to its internal combustion engine (ICE). It can be powered using electricity alone, and can also be charged by an external source of electricity. An Electric Vehicle (EV) only uses electricity as a source of power.
"fuel_type_primary", -- The source of power that is most often used to power a vehicle
"county", -- The geographic region of a state that a vehicle's owner is listed to reside within
"vehicle_primary_use", -- The way a vehicle was registered to be used through Department of Licensing; similar to ‘use class’
"vehicle_type", -- The category of vehicle based on its physical appearance and/or intended use, as defined by the manufacturer
"transaction_channel", -- Describes how the activity was performed Online: the transaction completed remotely using a Department of Licensing internet-based applications In-person: the transaction was completed by a person while visiting a Department of Licensing location By mail: the transaction was remotely requested and paid for via the United States Postal Service (USPS) or a mail courier
"state", -- This describes the residential or business location of the primary vehicle owner
"vehicle_record_count", -- A count of the title transactions based on the fields defined in this dataset
"primary_color", -- The color of the vehicle. Color is not required and may not be collected when registering or titling a vehicle.
"new_or_used_vehicle", -- When a vehicle is being sold by its manufacturer to its first owner, it it considered 'new'. Otherwise it is considered 'used'.
"transaction_type", -- The category of activity that was performed, as defined by Department of Licensing
"fuel_type_secondary", -- An additional source of power that is used to propel the vehicle
"model_year", -- The model year of the vehicle, determined by decoding the Vehicle Identification Number (VIN)
"owner_type", -- Describes if a vehicle is registered by one or more individuals, or a business
"_2020_census_tract", -- 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, 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
"make", -- The manufacturer of the vehicle, determined by decoding the Vehicle Identification Number (VIN)
"start_of_month", -- The month and year in which a transaction was recorded into Department of Licensing's computer system
"model", -- The model of the vehicle, determined by decoding the Vehicle Identification Number (VIN)
"gross_vehicle_weight_rating_class", -- A numeric classification (1-8) for the maximum operating weight of a vehicle including its chassis, body, engine, engine fluids, fuel, accessories, driver, passengers and cargo. Typically associated with Trucks.
"gross_vehicle_weight_rating_range", -- The weight range (in pounds) of the maximum operating weight of a vehicle including its chassis, body, engine, engine fluids, fuel, accessories, driver, passengers, and cargo. Typically associated with Trucks.
"zip_code" -- The 5 digit postal code used by the United States Postal Service (USPS) that a vehicle's owner is listed to reside within
FROM
"wa-gov/vehicle-title-transactions-by-department-of-cdk6-5kdf:latest"."vehicle_title_transactions_by_department_of"
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/vehicle-title-transactions-by-department-of-cdk6-5kdf
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/vehicle-title-transactions-by-department-of-cdk6-5kdf: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/vehicle-title-transactions-by-department-of-cdk6-5kdf
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/vehicle-title-transactions-by-department-of-cdk6-5kdf:latest
This will download all the objects for the latest
tag of wa-gov/vehicle-title-transactions-by-department-of-cdk6-5kdf
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/vehicle-title-transactions-by-department-of-cdk6-5kdf: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/vehicle-title-transactions-by-department-of-cdk6-5kdf: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/vehicle-title-transactions-by-department-of-cdk6-5kdf
is just another Postgres schema.