ct-gov/connecticut-business-registry-business-master-n7gp-d28j
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 connecticut_business_registry_business_master table in this repository, by referencing it like:

"ct-gov/connecticut-business-registry-business-master-n7gp-d28j:latest"."connecticut_business_registry_business_master"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "records_address_country", -- Records Address Country
    "records_address_city", -- Records Address City
    "records_address_unit", -- Records Address Unit
    "records_address_street", -- Records Address Street
    "record_address", -- Records Address
    "office_in_jurisdiction_country", -- Office Jurisdiction Country
    "office_jurisdiction_1", -- Office Jurisdiction State
    "office_jurisdiction_3", -- Office Jurisdiction Unit
    "office_jurisdiction_2", -- Office Jurisdiction Street
    "naics_sub_code", -- NAICS Subcode
    "naics_code", -- NAICS Code
    "mailing_jurisdiction", -- Mailing Jurisdiction City
    "mailing_jurisdiction_2", -- Mailing Jurisdiction Street
    "mailing_international_address", -- Mailing International Address
    "dissolution_date", -- If the entity is dissolved, the date it dissolved.  This is also the withdrawal date if a foreign registered entity
    "formation_place", -- Formation Place
    "date_registration", -- For domestic businesses, this is the date the business was formed.  For foreign businesses, this is the date they registered in Connecticut.
    "country_formation", -- Country of Formation
    "business_email_address", -- Business Email Address
    "billingpostalcode", -- Business Zip Code
    "annual_report_due_date", -- Annual Report Due Date
    "accountnumber", -- Business ID number (Authoritative Legal Entity Identifier) Unique
    "status", -- Business Status
    "business_type", -- Business Type
    "category_survey_email_address", -- Email address provided on business survey
    "office_jurisdiction_address", -- Office Jurisdiction Address
    "billingstreet", -- Business Street
    "mailing_jurisdiction_country", -- Mailing Jurisdiction_Country
    "business_name_in_state_country", -- Name of the business in the jurisdiction of formation, if foreign registered entity
    "billingcountry", -- Business Country
    "id", -- System generated unique identifier.  This is the unique key to associate the subsidiary data sets. 
    "create_dt", -- Date this data set was last refreshed
    "woman_owned_organization", -- Survey result for woman-owned
    "mailing_jurisdiction_3", -- Mailing Jurisdiction Unit
    "date_of_organization_meeting", -- Date of Organization Meeting
    "billing_unit", -- Business Unit
    "sub_status", -- Business sub-status
    "geo_location",
    "mailing_jurisdiction_4", -- Mailing Jurisdiction Zip Code
    "began_transacting_in_ct", -- Date business began transacting business in CT, if a foreign registered entity
    "name", -- Business Name
    "total_authorized_shares", -- Total Authorized Shares
    "records_address_zip_code", -- Records Address Zip Code
    "reason_for_administrative", -- If the entity was administratively dissolved/forfeited, the reason for administrative dissolution
    "office_jurisdiction_4", -- Office Jurisdiction Zip Code
    "mailing_jurisdiction_1", -- Mailing Jurisdiction State
    "mailing_address", -- Mailing Address
    "mail_jurisdiction", -- Mail Jurisdiction International Address
    "billingstate", -- Business State
    "billingcity", -- Business City
    "records_address_state", -- Records Address State
    "org_owned_by_person_s_with", -- Survey result for owned by person with a disability
    "minority_owned_organization", -- Survey result for minority-owned
    "citizenship", -- Formation jurisdiction
    "organization_is_lgbtqi_owned", -- Survey result for LGBTQI-owned
    "office_jurisdiction", -- Office Jurisdiction City
    "mailing_jurisdiction_address", -- Mailing Jurisdiction Address
    "state_or_territory_formation", -- Formation State Or Territory
    "veteran_owned_organization", -- Survey result for veteran-owned
    ":@computed_region_m4y2_whse", -- This column was automatically created in order to record in what polygon from the dataset 'Town Index' (m4y2-whse) the point in column 'geo_location' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_nhmp_cq6b", -- This column was automatically created in order to record in what polygon from the dataset 'Zip Code' (nhmp-cq6b) the point in column 'geo_location' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_dam5_q64j", -- This column was automatically created in order to record in what polygon from the dataset 'Counties' (dam5-q64j) the point in column 'geo_location' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_snd5_k6zv" -- This column was automatically created in order to record in what polygon from the dataset 'Planning Regions' (snd5-k6zv) the point in column 'geo_location' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
FROM
    "ct-gov/connecticut-business-registry-business-master-n7gp-d28j:latest"."connecticut_business_registry_business_master"
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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j 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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j: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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j

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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j:latest

This will download all the objects for the latest tag of ct-gov/connecticut-business-registry-business-master-n7gp-d28j 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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j: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 ct-gov/connecticut-business-registry-business-master-n7gp-d28j: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, ct-gov/connecticut-business-registry-business-master-n7gp-d28j is just another Postgres schema.

Related Documentation:

Loading...