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 beneficiarios_estrategia_unidos
table in this repository, by referencing it like:
"datos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8:latest"."beneficiarios_estrategia_unidos"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"rangoedad", -- Rango en el cual se encuentra la edad del beneficiario
"codigofamilia", -- Código de la familia a la cual pertenece el beneficiario
"he17", -- ¿Cuentas personas conforman este hogar?
"he13", -- ¿El predio donde se encuentra la vivienda es propio?
"logro25", -- Vinculación Actividad Productiva
"logro12", -- Libreta Militar
"logro6", -- Educación Inicial
"logro2", -- Aseguramiento
"discapacidad", -- Indica si el beneficiario tiene o no tiene discapacidad así: SI, NO
"condicionsexual", -- La orientación sexual hace referencia a la dirección del deseo erótico y la afectividad de las personas en razón al sexo o identidad de género de las otras personas. Orientación sexual del beneficiario así: BISEXUAL, GAY, LESBIANA, HETEROSEXUAL o ND
"codigomunicipioatencion", -- Código DIVIPOLA del municipio de atención del programa
"pe43", -- ¿Actualmente trabaja o tiene un negocio propio?
"estrato", -- Estrato social del beneficiario
"nombredepartamentoatencion", -- Nombre del departamento de atención del programa
"he23", -- ¿Usted o algún adulto en su hogar tuvo una alimentación basada en poca variedad de alimentos?
"he16", -- ¿La vivienda tiene inodoro conectado a alcantarillado o inodoro conectado a pozo séptico?
"logro16", -- Derechos Sexual Reproductivos
"pe41", -- ¿Actualmente está estudiando?
"pe45", -- ¿Uso computador o Tablet último mes?
"logro19", -- Herramientas Digitales
"he21", -- ¿Algún menor de 18 años del hogar dejo de desayunar, almorzar o cenar?
"logro11", -- Ingreso Superior Línea De Pobreza Extrema
"genero", -- Sexo de nacimiento del beneficiario así: H U HOMBRE, M O MUJER, I O INTERSEXUAL
"pe36", -- ¿Está incluido en el RLCPD?
"logro8", -- Trabajo Infantil
"pe40", -- ¿Sabe leer y escribir?
"pe46", -- ¿El niño / niña presenta edema en el empeine?
"estadobeneficiario", -- Estado en el que se encuentra el beneficiario “Activo”, “Atendido”, “Retirado”, “Inscrito” o “Suspendido”
"logro22", -- Paredes
"he14", -- ¿Algún integrante del hogar tiene escritura registrada de esa vivienda?
"he18", -- ¿En cuántos cuartos duermen las personas de este hogar?
"pe48", -- ¿Ha tenido fiebre, vomito, diarrea en los últimos 15 días?
"logro5", -- Crecimiento Y Desarrollo
"logro9", -- Acceso A Agua
"logro1", -- Documentos De Identidad
"logro3", -- Vacunación
"logro24", -- Ingreso Propio Adulos Mayores
"pe44", -- ¿Participo en cursos de educación financiera?
"logro17", -- Leer Y Escribir
"pe35", -- ¿Tiene discapacidad?
"codigodepartamentoatencion", -- Código DIVIPOLA del departamento de atención del programa
"tipodocumento", -- Sigla correspondiente al tipo de documento de identidad así: RC O REGISTRO CIVIL, TI O TARJETA DE IDENTIDAD, CC O CÉDULA DE CIUDADANÍA, CE O CÉDULA DE EXTRANJERÍA
"he12", -- ¿La vivienda tiene mayoritariamente pisos en tierra?
"he22", -- ¿En su hogar se quedaron sin alimentos?
"estadocivil", -- Estado civil del beneficiario así: CA o CASADO, DI o DIVORCIADO, SO o SOLTERO, UL o UNIÓN LIBRE, VI o VIUDO
"pe38", -- ¿Recibió producto apoyo?
"logro13", -- RLCPD
"pais", -- País de donde es el beneficiario
"beneficiariosisben", -- Si el beneficiario tiene o no Sistema de Potenciales Beneficiarios para programas sociales (SISBEN)
"pe34", -- ¿Esta afiliado al SGSSS?
"tipopoblacion", -- A la que atiende cada programa
"pe37", -- ¿Prescribieron producto apoyo?
"logro23", -- Hacinamiento
"logro14", -- Productos De Apoyo Discapacidad
"puntajesisben", -- Código de valores del Puntaje Sisben, Rango de los valores: 1: entre 0 y 10; 2: entre 11 y 20; 3: entre 21 y 30; 4: Mayor a 31.
"he20", -- ¿En cuánto estima el monto de los ingresos de su hogar al mes?
"he15", -- ¿La vivienda cuenta con acueducto público, acueducto comunal / verdal, o pozo con bombas?
"he11", -- ¿Las paredes de la vivienda son mayoritariamente de bloque, ladrillo, piedra, madera pulida, concreto vaciado y / o material prefabricado?
"pe51", -- ¿Asiste a hogar comunitario, guardería, jardín infantil, CDI u otro servicio de ICB o el municipio?
"pe50", -- ¿Tiene esquema de vacunación al día según edad?
"pe42", -- ¿Cuál fue el último de grado aprobado?
"pe39", -- ¿Recibió orientación DD sexuales y reproductivas?
"logro26", -- Seguridad Jurídica Del Predio
"logro21", -- Pisos
"logro20", -- Educación Financiera
"logro18", -- Estudios Postsecundarios
"logro15", -- Seguridad Alimentaria
"logro10", -- Saneamiento Básico
"logro7", -- Acceso Sistema Educativo
"logro4", -- Tamizaje Desnutrición Aguda
"parentesco", -- La relación del beneficiario con los demás miembros de la familia
"etnia", -- Grupo étnico al que pertenece el beneficiario así: AFROCOLOMBIANO - NEGRO, INDIGENA, RAIZAL, ROM O GITANO, PALENQUERO o ND
"nombremunicipioatencion" -- Nombre del municipio de atención del programa
FROM
"datos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8:latest"."beneficiarios_estrategia_unidos"
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 datos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at www.datos.gov.co. When you querydatos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8: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
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 (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 clone
and sgr checkout
.
Mounting Data
This repository is an external repository. It's not hosted by Splitgraph. It is hosted by www.datos.gov.co, 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 \
"datos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8" \
--handler-options '{
"domain": "www.datos.gov.co",
"tables": {
"beneficiarios_estrategia_unidos": "snvf-epj8"
}
}'
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, datos-gov-co/beneficiarios-estrategia-unidos-snvf-epj8
is just another Postgres schema.