ny-gov/public-cemetery-corporations-5wzh-jq4n
Icon for Socrata external plugin

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 public_cemetery_corporations table in this repository, by referencing it like:

"ny-gov/public-cemetery-corporations-5wzh-jq4n:latest"."public_cemetery_corporations"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "communitymausoleum", -- 1 if the cemetery operates a mausoleum for public use, 0 otherwise.
    "abandonedtotownname", -- Name of town to which cemetery was abandoned.  Blank if the cemetery was not abandoned to the jurisdiction of a town.
    "takenoverbycemetery", -- CEMID of cemetery to which the cemetery was abandoned or merged. Blank if the cemetery was not abandoned to or merged with another cemetery.
    "activesince", -- Estimated date when cemetery began operation. Blank if unknown.
    "status", -- Operating status of the cemetery corporation. “Active” means that the cemetery is active and under the Division's jurisdiction. “Merged to Cemetery” means that the cemetery merged with another cemetery.  The assigned cemetery is the merged entity that now operates this cemtery. “Abandoned to Cemetery” means that the cemetery was abandoned and transferred to the custody of another cemetery. “Abandoned to Town” means that the cemetery was abandoned and transferred to the custody of a town government. “Dissolved” means that the cemetery underwent the process by which a cemetery corporation ceases to exist. “Other” means that the cemetery is no longer under division jurisdiction for another reason.
    "cemetery_name", -- Name of the cemetery corporation.
    "abandonedtotownmunicode", -- Unique identifier of the town to which cemetery was abandoned. The identifier is the 12-digit local government entity identifier assigned to the town by the Office of State Comptroller (see https://osc.state.ny.us/localgov/datanstat/entitytable.htm).  Blank if the cemetery was not abandoned to a town jurisidiction.
    "abandonedormergedon", -- Estimated date when cemetery ceased to be an independent entity through merger or abandonment. 
    "nontraditional", -- 1 if 'non-traditional cemetery corporation,' defined as 'any cemetery corporation which does not offer and has not in the past offered full body ground burials' (19 NYCRR 200.1(d)(4)]; 0 if otherwise.
    "crematory", -- 1 if cemetery corporation operates a crematory, 0 otherwise.
    "county", -- County in which cemetery corporation is located
    "cemid" -- Unique five-digit identifier issued by the Division of Cemeteries to every cemetery corporation under its jurisdiction.  The first two digits correspond to the county in which the cemetery is located, starting at “01”.  The last three are issued sequentially, starting at “001”.
FROM
    "ny-gov/public-cemetery-corporations-5wzh-jq4n:latest"."public_cemetery_corporations"
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 ny-gov/public-cemetery-corporations-5wzh-jq4n with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.ny.gov. When you queryny-gov/public-cemetery-corporations-5wzh-jq4n:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

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 (like this repository), 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, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.ny.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "ny-gov/public-cemetery-corporations-5wzh-jq4n" \
  --handler-options '{
    "domain": "data.ny.gov",
    "tables": {
        "public_cemetery_corporations": "5wzh-jq4n"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

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, ny-gov/public-cemetery-corporations-5wzh-jq4n is just another Postgres schema.