oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2
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 oregon_active_workers_compensation_employer table in this repository, by referencing it like:

"oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2:latest"."oregon_active_workers_compensation_employer"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "mail_address2", -- Street address line of employer’s mailing address
    "ncci_code", -- NCCI insurance classification code
    "insurer_name", -- Name of insurer providing workers’ compensation insurance coverage
    "insurer_status_date", -- Date when the insured status code was assigned. Provided in the format mm/dd/yyyy.
    "ppb_zip", -- Zip code of employer’s principle place of business
    "record_origin", -- Employers are assigned a PC1 or PC2 code based on the primary entity being insured. A missing value in this field means that the employer is self-insured. PC1: Employer is the insured on the policy. PC2: Employer is a covered entity on the policy and the Federal ID Number (FEIN) reported for this entity is different than the FEIN of the insured.
    "mail_city", -- City of employer’s mailing address
    "liab_begin_date", -- Employer coverage liability begin date
    "county_code", -- County code for employer’s location
    "ppb_zip_4", -- Zip code +4 for employer’s principle place of business
    "mail_zip_4", -- Zip code +4 of employer’s mailing address
    "mail_address1", -- Attention, in care of, or other address info for employer’s mailing address
    "phone_area", -- Area code for employer’s phone number
    "entity_code", -- Employer entity codes consist of a single alphanumeric character classifying employers by entity type. 0 = Other 1 = Individual 2 = Corporation 3 = Political Subd 4 = Husband/Wife Partnership 5 = Partnership 6 = Joint Venture 7 = Association 8 = Labor Union  9 = Limited Partner A = LLP B = LLC C = Trust D = Estate
    "liad_end_date", -- Employer coverage liability end date
    "insurer_num", -- Insurer number is a 1- to 4-digit number assigned by DCBS to identify insurance providers
    "ppb_city", -- City of employer’s principle place of business
    "ppb_address2", -- Street address line of employer’s principal place of business address
    "naics", -- The North American Industry Classification System Code is a 6-digit code used to classify employers into industries based on similarity of production processes.
    "ownership", -- Employer ownership code is a two-digit number identifying the type of ownership. 10 (Federal Government) 20 (State Government) 30 (Local Government) 50 (Private Ownership)
    "legal_business_name", -- The legal business name of the employer
    "mail_zip", -- Zip code of employer’s mailing address
    "phone", -- Employer’s phone number
    "ppb_address1", -- Attention, in care of, or other address info for employer’s principal place of business address
    "naics_description", -- NAICS code industry title
    "dba_name", -- The doing business as name of the employer
    "insurer_status", -- The insured status code is a two-digit number identifying the employer’s current coverage status. 01 = Active Coverage 03 = Double Coverage 04 = Pending Coverage 12 = Pending Investigation
    "mail_state", -- State of employer’s mailing address
    "employees_range", -- Employees range categorizes employers into one of five groups based on the number of employees reported. Actual employment numbers are suppressed for confidentiality. The five size categories:
    "employer_num", -- Employer number is a 7-digit number assigned by DCBS to identify each unique employer.  Employer numbers fall within the range of 1000000 to 9999999.
    "ppb_state" -- State of employer’s principle place of business
FROM
    "oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2:latest"."oregon_active_workers_compensation_employer"
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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2 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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2: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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2

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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2:latest

This will download all the objects for the latest tag of oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2 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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2: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 oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2: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, oregon-gov/oregon-active-workers-compensation-employer-q9zj-c8r2 is just another Postgres schema.

Related Documentation:

Loading...