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 post_secondary_completions_total_awardsdegrees_sy
table in this repository, by referencing it like:
"pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg:latest"."post_secondary_completions_total_awardsdegrees_sy"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"doctor_s_degree_professional_practice", -- A doctor's degree that is conferred upon completion of a program providing the knowledge and skills for the recognition, credential, or license required for professional practice. The degree is awarded after a period of study such that the total time to the degree, including both pre-professional and professional preparation, equals at least six full-time equivalent academic years. Some of these degrees were formerly classified as firstprofessional and may include: Chiropractic (D.C. or D.C.M.); Dentistry (D.D.S. or D.M.D.); Law (J.D.); Medicine (M.D.); Optometry (O.D.); Osteopathic Medicine (D.O); Pharmacy (Pharm.D.); Podiatry (D.P.M., Pod.D., D.P.); or, Veterinary Medicine (D.V.M.), and others, as designated by the awarding institution.
"bachelor_s_degree", -- An award (baccalaureate or equivalent degree, as determined by the Secretary, U.S. Department of Education) that normally requires at least 4 but not more than 5 years of full-time equivalent college-level work. This includes all bachelor's degrees conferred in a 5-year cooperative (work-study) program. A cooperative plan provides for alternate class attendance and employment in business, industry, or government; thus, it allows students to combine actual work experience with their college studies. Also includes bachelor's degrees in which the normal 4 years of work are completed in 3 years.
"associate_s_degree", -- An award that normally requires at least 2 but less than 4 years of full-time equivalent college work.
"institution_name", -- The name of the institution.
"doctor_s_degree_research_scholarship", -- A Ph.D. or other doctor's degree that requires advanced work beyond the master's level, including the preparation and defense of a dissertation based on original research, or the planning and execution of an original project demonstrating substantial artistic or scholarly achievement. Some examples of this type of degree may include Ed.D., D.M.A., D.B.A., D.Sc., D.A., or D.M, and others, as designated by the awarding institution.
"master_s_degree", -- An award that requires the successful completion of a program of study of at least the full-time equivalent of 1 but not more than 2 academic years of work beyond the bachelor's degree. Some of these degrees, such as those in Theology (M.Div., M.H.L./Rav) that were formerly classified as "firstprofessional", may require more than two full-time equivalent academic years of work.
"unit_id", -- Unique identification number assigned to postsecondary institutions surveyed through the Integrated Postsecondary Education Data System (IPEDS). Also referred to as UNITID or IPEDS ID.
"year", -- School Year
"doctor_s_degree_other" -- A doctor's degree that does not meet the definition of a doctor's degree - research/scholarship or a doctor's degree - professional practice.
FROM
"pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg:latest"."post_secondary_completions_total_awardsdegrees_sy"
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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg
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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg: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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg
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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg:latest
This will download all the objects for the latest
tag of pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg
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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg: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 pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg: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, pa-gov/post-secondary-completions-total-awardsdegrees-sy-jqcu-bcsg
is just another Postgres schema.