Query the Data Delivery Network
Query the DDNThe 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 los_angeles_businesssource_centers_micro_startups
table in this repository, by referencing it like:
"lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud:latest"."los_angeles_businesssource_centers_micro_startups"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"number_of_fte_jobs_retained", -- Full time jobs retained through the direct services of the LABSC; 51% of jobs retained must meet HUD definition of Low-Moderate Income.
"number_of_loans_approved", -- Unit count of all loans provided to Prestartups, Startups, and Operating Businesses that are approved for a loan. Must include information sufficient to substantiate a legitimate loan approval and loan amount as submitted by approving Lender.
"number_who_launched_a_business", -- A Startup that established a legal business license required and satisfactory secondary evidence (i.e. business bank account, website, rental agreement, POS system purchase, etc.).
"number_who_completed_coursework", -- Prestartups, Startups, and Operating Businesses that complete a workshop or business course. This includes, but is not limited to, Access to Capital training class.
"number_enrolled", -- All customers that appear to fall within one of the following specified categories of clientele who are generally presumed eligible, i.e., to be “very low (low ) and low (moderate ) income persons”: abused children, battered spouses, elderly persons, adults meeting the definition of “severely disabled” as specified below, homeless persons, illiterate adults, persons living with AIDS and migrant farm workers. Prestartups, Startups, and Operating Businesses that are deemed eligible, are officially enrolled in a LABSC, and were provided a business service.
"number_of_pte_jobs_retained", -- Part time jobs retained through the direct services of the LABSC; 51% of jobs retained must meet HUD definition of Low-Moderate Income. NOTE: Part Time Jobs must be aggregated to reach Full Time Equivalent (FTE) status to meet contractual goal.
"number_of_referrals_to_wsc", -- Documented evidence of acceptance of referral of an Operating Business to a WorkSource Center.
"number_of_loans_funded", -- Dollar amount of all loans provided to Operating Businesses, including information sufficient to substantiate an acceptance of loan funds from Lender on Lender letterhead and signed by Prestartups, Startups, and Operating Business.
"loan_amount_packaged", -- Prestartups, Startups, and Operating Businesses that submitted required paperwork for review by potential Lender after completing Access to Capital.
"number_provided_access_to_capital", -- Prestartups, Startups, and Operating Businesses that are given one-on-one consultation on how to access capital based on one or more of the following: • Financial Analysis • Personal Credit Report Review • Personal Credit Building/Correction • Business Credit Report Review • Business Credit Building/Correction • Projections Preparation/Modification • Marketing Plan Development/Analysis • Lease Evaluation/Negotiation
"number_of_opened_new_locations", -- An Operating Business that opened an additional location in the City of LA as a result of direct services by an LABSC (business license required and secondary evidence, i.e. bank account, website, rental agreement, POS system purchase).
"loan_amount_funded", -- Dollar amount of all loans provided to Operating Businesses, including information sufficient to substantiate an acceptance of loan funds from Lender on Lender letterhead and signed by Prestartups, Startups, and Operating Business.
"number_of_loans_packaged", -- Prestartups, Startups, and Operating Businesses that submitted required paperwork for review by potential Lender after completing Access to Capital.
"number_of_fte_jobs_created", -- Full time jobs created through the direct services of the LABSC; 51% of jobs created must meet HUD definition of Low-Moderate Income.
"number_who_were_provided_a_business_service", -- Prestartups, Startups, and Operating Businesses that receive a Business Service, including but not limited to: • Needs Assessment (ALL Prestartups/Startups shall receive a Needs Assessment) • Permits/Licenses • Business Plan/Executive Summary • Certification • Market Assessment • Site-Finding Assistance • Lease Negotiation Assistance • Cash Flow Management • Tax • Consulting • Procurement • Legal Considerations • One-on-One Consulting • Referral to SCORE • Referral to Other Partners
"number_of_pte_jobs_created", -- Part time jobs created through the direct services of the LABSC; 51% of jobs created must meet HUD definition of Low-Moderate Income. NOTE: Part Time Jobs must be aggregated to reach Full Time Equivalent (FTE) status to meet contractual goal.
"number_of_referrals_to_partner", -- Documented evidence of acceptance of referral of Startups, and Operating Businesses to Procurement/Export Partners or one of 9 City of LA Agencies.
"loan_amount_approved" -- Dollar amount of all loans provided to Prestartups, Startups, and Operating Businesses that are approved for a loan. Must include information sufficient to substantiate a legitimate loan approval and loan amount as submitted by approving Lender.
FROM
"lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud:latest"."los_angeles_businesssource_centers_micro_startups"
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 lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud: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 lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud
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 lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud:latest
This will download all the objects for the latest
tag of lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud
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 lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud: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 lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud: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, lacity/los-angeles-businesssource-centers-micro-startups-jg4k-s4ud
is just another Postgres schema.