wa-gov/lobbyist-summary-c4ag-3cmj
Loading...

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

"wa-gov/lobbyist-summary-c4ag-3cmj:latest"."lobbyist_summary"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "net_total", -- This column is the total of all expenses and compensation, minus sub lobbyist compensation.
    "advertising", -- The total amount of all advertising expenses incurred by the lobbyist, from all employers for a given year.  Advertising expenses include advertising costs, printing costs, and the cost of informational literature.
    "political_ads", -- The total amount of all political advertising expenses incurred by the lobbyist, from all employers for a given year.  Political advertising expenses are expenditures for political advertising supporting or opposing a state or local candidate or ballot measure; or public relations, telemarketing, polling or similar activities that directly or indirectly are lobbying-related.
    "year", -- The year of registration for the lobbyist. A lobbyist can be registered in multiple years.
    "total_expenses", -- This column is a total of all "expenses" incurred by the lobbyist for all employers for a given year. NOTE: this total does not include compensation.  It is the sum of "personal expenses" + "entertainment" + "contributions" + "advertising" + "political advertising" + "other expenses".
    "filer_id", -- The unique id assigned to a lobbyist. The filer id is consistent across year.  
    "pac_contributions", -- The total amount of all monetary or in-kind contribution exceeding $25 that were given by the employers PAC and transmitted by the lobbyist
    "temp_phone", -- The temporary telephone number of the lobbyist during legislative session. This is usually a cell phone or the number of the "Third House".
    "contributions", -- The total amount of all contributions transmitted by the lobbyist, from all employers for a given year. Contributions include monetary or in-kind contributions, exceeding $25, given or transmitted by the lobbyist to local and state candidates or elected officials; local and state officers or employees; political committees supporting or opposing any candidate, elected official, officer or employee or any local or state ballot proposition a caucus political committee; a political party; or a grass roots lobbying campaign.
    "other", -- The total amount of other expenses incurred by the lobbyist, from all employers for a given year. Other expenses are: Payments by the lobbyist for other lobbying expenses and services, including payments to subcontract lobbyists, expert witnesses and others retained to provide lobbying services or assistance in lobbying and payments for grass roots lobbying campaigns.  Advertising and printing costs are not included in other expenses.
    "entertainment", -- The total amount of all entertainment expenses incurred by the lobbyist, from all employers for a given year. Expenditures that were incurred by lobbyist or lobbyist employer(s) for legislators, state officials, state employees and members of their immediate families. • Entertainment expenditures exceeding $50 per occasion (including lobbyist’s expense) for meals, beverages, tickets, passes, or for other forms of entertainment. • Travel, lodging and subsistence expenses in connection with a speech, presentation, appearance, trade mission, seminar or educational program. • Enrollment and course fees in connection with a seminar or educational program.
    "temp_address", -- The temporary address of the lobbyist during legislative session.
    "indirect_lobbying_expenses", -- For use at a future date
    "temp_city", -- The temporary city of the lobbyist during legislative session.
    "temp_state", -- The temporary state of the lobbyist during legislative session.
    "temp_zip", -- The temporary zip code of the lobbyist during legislative session.
    "personal_expenses", -- The total amount of all personal expenses for travel, food and refreshments incurred by the lobbyist, from all employers for a given year.
    "net_compensation", -- The compensation the lobbyist received after paying any subcontracted lobbyists.
    "temp_country", -- The temporary country of the lobbyist during legislative session.
    "firm_address", -- The street address of the lobbyist, usually a mailing address.
    "firm_city", -- The city of the registered lobbyist.
    "firm_state", -- The state of the registered lobbyist.
    "lobbyist_phone", -- The permanent telephone number of the lobbyist.
    "id", -- PDC internal identifier that corresponds to a lobbyist's unique filer id combined with the year of registration.  For example an id of 17239-2017 represents a record  for a lobbyist whose filer id is 17239 for calendar year 2017. 
    "lobbyist_email", -- The e-mail address of the lobbyist per their registration.
    "sub_lobbyist_compensation", -- Payments to other lobbyists hired by the lobbyist or paid by the lobbyist from a portion of the funds received from the employer.
    "lobbyist_name", -- The lobbyist's name as registered. The name will be consistent across all records for the same filer id and election year but may differ across years due to a lobbyist changing their name.
    "firm_zip", -- The zip code of the registered lobbyist.
    "compensation", -- The total amount of compensation received, by the lobbyist, from all employers for a given year.
    "direct_lobbying_expenses", -- For use at a future date
    "firm_country" -- The country where the lobbyist firm resides.
FROM
    "wa-gov/lobbyist-summary-c4ag-3cmj:latest"."lobbyist_summary"
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/lobbyist-summary-c4ag-3cmj with SQL in under 60 seconds.

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, 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 cloneand sgr checkout.

Cloning Data

Because wa-gov/lobbyist-summary-c4ag-3cmj: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/lobbyist-summary-c4ag-3cmj

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/lobbyist-summary-c4ag-3cmj:latest

This will download all the objects for the latest tag of wa-gov/lobbyist-summary-c4ag-3cmj 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/lobbyist-summary-c4ag-3cmj: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/lobbyist-summary-c4ag-3cmj: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/lobbyist-summary-c4ag-3cmj is just another Postgres schema.

Related Documentation:

Loading...