wa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi
Icon for Socrata external plugin

Query the Data Delivery Network

Query the DDN

The 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 pre2016_lobbyist_compensation_and_expenses_by table in this repository, by referencing it like:

"wa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi:latest"."pre2016_lobbyist_compensation_and_expenses_by"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "new_employer_id", -- If this employer files electronically using the PDC Accesshub online filing system, this is their identifier in that system.
    "contributions", -- This is the sum total of contributions reported for this  L2 and filing period.
    "personal_expenses", -- This is the sum total of personal expenses reported for this  L2 and filing period.
    "compensation", -- This is the sum total of compensation reported for this employer on this L2.
    "employer_name", -- This is the title of the employer as reported when filing electronically using the  PDC Accesshub online filing system.
    "receipt_date", -- The date that the report was filed.
    "funding_source_name", -- This is the title of the Firm/Employer relationship for this L2.
    "funding_source_id", -- This is the unique identifier of the funding source for this L2 and corresponds to the filer_id of this filing entity.
    "filer_name", -- This is the title of the lobbyist or lobbyist firm, as reported when filing electronically using the  PDC Accesshub online filing system.
    "filer_id", -- This is the unique lobbyist id for this lobbyist, and matches the lobbyist  identifier in the PDC Accesshub online filing system.
    "origin", -- This column shows the origin of the record. FL = Legacy L2 Filing (prior to 2016).
    "report_number", -- This is a unique report number assigned to this report. The number is created by concatenating the filer_id with the report date.
    "new_filer_id", -- If this filer files electronically using the PDC Accesshub online filing system, this is their identifier in that system.
    "other", -- This is the sum total of other expenses reported for this  L2 and filing period.
    "political_ads", -- This is the sum total of political ads expenses reported for this  L2 and filing period.
    "advertising", -- This is the sum total of advertising expenses  reported for this  L2 and filing period.
    "filing_period", -- The filing period for this report.
    "entertainment", -- This is the sum total of entertainment expenses reported for this  L2 and filing period.
    "employer_id", -- This is the unique employer id for this employer, and matches the employer  identifier in the PDC Accesshub online filing system.
    "type", -- Shows if this report was filed for an employer or for a lobbyist.
    "id" -- This is the unique identifier for this dataset.
FROM
    "wa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi:latest"."pre2016_lobbyist_compensation_and_expenses_by"
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/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.wa.gov. When you querywa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi: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

Install Splitgraph Locally
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; sgrcan 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 cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.wa.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 \
  "wa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi" \
  --handler-options '{
    "domain": "data.wa.gov",
    "tables": {
        "pre2016_lobbyist_compensation_and_expenses_by": "3v2j-kqbi"
    }
}'

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, wa-gov/pre2016-lobbyist-compensation-and-expenses-by-3v2j-kqbi is just another Postgres schema.