cityofnewyork-us/sbs-certified-business-list-ci93-uc8s
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 sbs_certified_business_list table in this repository, by referencing it like:

"cityofnewyork-us/sbs-certified-business-list-ci93-uc8s:latest"."sbs_certified_business_list"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "last_name", -- Last Name of the Company's Contact Person
    "telephone", -- Telephone Number
    "certification", -- Type of Certification the company qualified for
    "bin", -- The BIN (Building Identification Number) is a unique identifier for each building in the City
    "naics_sector", -- NAICS sector (Industry)
    "mailingaddress2", -- Company mailing address
    "zip", -- ZIP code 
    "mailingcity", -- City 
    "address1", -- Company Address
    "council_district", -- The Council District field indicates the New York City Council District where the building is located
    "date_of_establishment", -- Date the Company was Established
    "website", -- Company Website 
    "mailingstate", -- State
    "longitude", -- Longitude of the building's location
    "latitude", -- Latitude of the building's location
    "capacity_building_programs",
    "ethnicity", -- Ethnicity of the Company owner(s)
    "address2", -- Company Address
    "account_number", -- Vendor Number
    "business_description", -- A brief description of the type of service provided
    "cert_renewal_date", -- Date on which certification was renewed
    "state", -- State in which Company is located
    "aggregate_bonding_limit", -- Bonding Limit
    "naics_subsector", -- NAICS  Subsector
    "types_of_construction_projects_performed", -- Type of jobs performed in the construction industry
    "nigp_codes", -- National Institute of Governmental Purchasing (NIGP) Codes 
    "name_of_client_job_exp_1", -- The Business the vendor is working for
    "date_of_work_job_exp_1", -- Date the work was done
    "name_of_client_job_exp_3", -- Name of third business the vendor is working for 
    "enrolled_in_passport", -- Enrollment in the NYC's Procurement and Sourcing Solutions Portal (PASSPort) 
    "borough", -- Borough in which the building is located
    "value_of_contract_job_exp_3", -- Value (in dollars) of the the contract
    "description_of_work_job_exp_1", -- Description of the work done 
    "first_name", -- First Name of the Company's Contact Person
    "census_tract_2020_", -- The Census Tract (Census 2020) field indicates the U.S. Census Tract where the building is located. Please note that as part of the geocoding process, leading and trailing zeros are dropped
    "bbl", -- The BBL (Borough, Block, and Lot) is a unique identifier for each tax lot in the City
    "date_of_work_job_exp_3", -- Date the work was done
    "neighborhood_tabulation_area_nta_2020_", -- The Neighborhood Tabulation Area (Census 2020) field indicates the New York City Neighborhood area where the building is located 
    "percent_self_performed_job_exp_1", -- Percent of the job performed by the vendor  
    "description_of_work_job_exp_2", -- Description of the work done 
    "signatory_to_union_contracts", -- Signatory to Union contracts
    "mailingzip", -- ZIP code 
    "description_of_work_job_exp_3", -- Description of the work done
    "percent_self_performed_job_exp_3", -- Percent of the job performed by the vendor  
    "mailingaddress1", -- Company mailing address
    "city", -- City in which Company is located
    "vendor_formal_name", -- Formal Name of the Company
    "date_of_work_job_exp_2", -- Date the work was done 
    "id6_digit_naics_code", -- North American Industry Classification System (NAICS) Code that identifies the type of business 
    "percent_self_performed_job_exp_2", -- Percent of the job performed by the vendor  
    "value_of_contract_job_exp_2", -- Value (in dollars) of the the contract 
    "name_of_client_job_exp_2", -- Name of second business the vendor is working for 
    "largest_value_of_contract", -- Value (in dollars) of the the contract 
    "naics_title", -- Type of Business 
    "community_board", -- The Community Board field indicates the New York City Community District where the building is located
    "vendor_dba" -- Name the Company goes by
FROM
    "cityofnewyork-us/sbs-certified-business-list-ci93-uc8s:latest"."sbs_certified_business_list"
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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s 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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s: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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s

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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s:latest

This will download all the objects for the latest tag of cityofnewyork-us/sbs-certified-business-list-ci93-uc8s 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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s: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 cityofnewyork-us/sbs-certified-business-list-ci93-uc8s: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, cityofnewyork-us/sbs-certified-business-list-ci93-uc8s is just another Postgres schema.

Related Documentation:

Loading...