cityofnewyork-us/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4
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 mayors_office_to_end_domestic_and_genderbased table in this repository, by referencing it like:

"cityofnewyork-us/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4:latest"."mayors_office_to_end_domestic_and_genderbased"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "language_interpretation_svcs", -- Indicates if language interpretation services are provided by the organization or program. Yes = language interpretation services provided No = language interpretation services not provided
    "wheelchair_access", -- Indicates if organization or program location is wheelchair accessible. Yes = wheelchair assessable No = not wheelchair accessible. 
    "hotline_hours_other", -- Provides the other days/times of the hours of operation of the hotline of organizations that provides domestic violence services; Hotline hours appear in this column if organization provides services during hours other than those already listed. 
    "other_specialized_svcs", -- Organization or program provides specialized services other individuals or populations listed.  Other types of services appear in column if organization or program provides services other than those already listed. 
    "borough", -- Indicates the borough that the organization is located in: Brooklyn; Bronx; Manhattan; Queens; Staten Island
    "hotline_hours", -- Provides the days/times of the hours of operation of the hotline of organizations that provides domestic violence services from list; Mon.= Monday; Fri.= Friday; Tues = Tuesday; Thurs.= Thursday; Sat.=Saturday; Sun.= Sunday; Weds = Wednesday  
    "display_physical_address", -- Indicates if there's a physical address that can be displayed for this record; Yes = A physical address can be displayed, No = a physical address cannot be displayed
    "svcs_provided", -- Organization or program provides services from list of categories. [Civil Legal Services; Immigration Legal Services; Family Court Legal Services; Community Education; Court/Police Accompaniment; Crisis Counseling; General Domestic Violence Services;  Elder Abuse Services; English as a Second Language Classes; Emergency Assistance/Transportation; Healing Arts/Theatre Programs; Health Services; HIV/AIDS Support Services; Job Training; Long Term Counseling; Lock Replacement; Play Therapy; Public Assistance; Sexual Assault Services; Services for Stalking Survivors; Teen Dating Survivor Services; Trafficking Victim Services; Shelter Assistance/Housing Assistance; Other]
    "nta", -- The Neighborhood Tabulation Area field indicates the New York City Neighborhood area where the organization or program is located.
    "tty", -- The TTY number for the organization or program that provides domestic violence services 
    "address", -- Physical address of the organization; If address is confidential, the value of this field will be "Please contact organization"
    "name", -- Name of this record; May be different from Organization and Program Name
    "longitude", -- Longitude of the organization or program
    "other_svcs_provided", -- Organization or program provides services other than those listed in other categories. The specific service provided appears in the column if organization or program provides services other than those already listed. 
    "program_hours", -- Provides the days/times of the hours of operation of the program offered by the organization that provides domestic violence services from list; 24/7;Mon - Fri: 9:00 AM - 5:00 PM; Other
    "specialized_svcs", -- Organization or program provides specialized services listed. [Survivors of Sexual Assault and DV; Child Witnesses to DV; People with HIV/AIDS; LGBTQ; Men; Immigrants; People with Substance Abuse Issues; Trafficking Survivors; Elder Abuse Survivors; Stalking Survivors; Survivors of Teen Dating Violence; People with Disabilities; Abusive Partners; Children at Risk of Abuse/Neglect; Teenagers; Other]
    "language_other", -- Provides services in other languages than those listed or has ability to provide language interpretation services in other languages. Other languages appear in column if organization or program provides languages other than those already listed. 
    "phone", -- Provides the hotline number for the organization or program that provides domestic violence services 
    "zip", -- Zip code of the address
    "id", -- Unique identifier of the record
    "census_tract", -- The Census Tract field indicates the U.S. Census Tract where the organization or program is located.
    "hotline_phone", -- Provides the hotline number for the organization or program that provides domestic violence services 
    "fax", -- The fax number of the organization or program that provides domestic violence services 
    "fee_svc", -- Indicates if there is a fee for services; Yes = fee for services No = no fee for services
    "bbl", -- The BBL (Borough, Block, and Lot) is a unique identifier for each tax lot in the City.
    "bin", -- The BIN (organization or program Identification Number) is a unique identifier for each organization or program in the City.
    "council_district", -- The Council District field indicates the New York City Council District where the organization or program is located.
    "community_board", -- The Community Board field indicates the New York City Community District where the organization or program is located.
    "latitude", -- Latitude of the organization or program
    "boroughs_served", -- Indicates the borough that the organization serves; Brooklyn; Bronx; Manhattan; Queens; Staten Island
    "program_hours_other", -- Provides other days/times of the hours of operation of the program offered by the organization that provides domestic violence services; Program hours appear in this column if organization provides services during hours other than those already listed. 
    "orgranization_and_program", -- The name of the organization & program providing the domestic violence services 
    "language_svcs", -- Provides services in listed languages. Albanian; American Sign Language (ASL); Arabic; Bengali; Chinese; English; French; Haitian Creole; Hindi; Korean; Polish; Russian; Spanish; Urdu; Other
    "url", -- Provides website address for the organization or program that provides domestic violence services
    "website" -- Provides website address for the organization or program that provides domestic violence services
FROM
    "cityofnewyork-us/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4:latest"."mayors_office_to_end_domestic_and_genderbased"
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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4 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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4: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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4

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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4:latest

This will download all the objects for the latest tag of cityofnewyork-us/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4 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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4: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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4: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/mayors-office-to-end-domestic-and-genderbased-5ziv-wcy4 is just another Postgres schema.

Related Documentation:

Loading...