datos-gov-co/inscripciones-electorales-en-el-exterior-7q36-mkp5
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 inscripciones_electorales_en_el_exterior table in this repository, by referencing it like:

"datos-gov-co/inscripciones-electorales-en-el-exterior-7q36-mkp5:latest"."inscripciones_electorales_en_el_exterior"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "grupo_edad", -- El grupo se basa en la edad de acuerdo a lo siguiente:  Entre 0 y 5 años Primera infancia Entre 6 y 11 años Infante Entre 12 y 18 años Adolescente Entre 19 y 28 años Adulto joven Entre 29 y 59 años Adulto Entre 60 en adelante Adulto Mayor. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "c_digo_iso_residencia", -- ISO del País de Residencia. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "oficina_inscripcion", -- Oficina ante la cual se realizo el proceso de inscripción electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "localizaci_n_residencia_city",
    "puesto_votaci_n", -- Puesto de Votación para el cual se realizo la inscripción electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "cantidad_preinscritos", -- Hace referencia a la cantidad de personas que se preinscriben en línea para un puesto de votación determinado. 
    "estado_civil", -- Estado Civil de las personas inscritas. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "mes_inscripci_n", -- Mes en que se realizo la inscripción electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "nivel_estudios", -- Nivel de estudión del inscrito electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA) 
    "localizaci_n_city",
    "proceso_electoral", -- Identificador del proceso electoral al que hace referencia la inscripción. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "g_nero", -- Género del inscrito electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "a_o_inscripci_n", -- Año en que se realizo la inscripción. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "localizaci_n_address",
    "pa_s_residencia", -- País de Residencia actual del inscrito electoral.  Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "cantidad_inscritos", -- hace referencia a la cantidad de personas que formalizan la preinscripción electoral registrada en línea ante una oficina. 
    "cantidad_total", -- Cantidad Total, es la sumatoria de los preinscritos e inscritos
    "localizaci_n_state",
    "localizaci_n_zip",
    "etnia_de_la_persona", -- Etnia del inscrito electoral. Cuando no se tienen datos registrados se presenta el texto (NO REGISTRA)
    "localizaci_n_residencia_address",
    "localizaci_n_residencia_state",
    "localizaci_n_residencia_zip",
    "localizaci_n", -- Localización del puesto de votación. Cuando no se tienen datos registrados se presenta el valor 0,0
    "localizaci_n_residencia" -- Ubicación de los inscritos electorales de acuerdo al registro consular.  Cuando no se tienen datos registrados se presenta el valor 0,0
FROM
    "datos-gov-co/inscripciones-electorales-en-el-exterior-7q36-mkp5:latest"."inscripciones_electorales_en_el_exterior"
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/inscripciones-electorales-en-el-exterior-7q36-mkp5 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/inscripciones-electorales-en-el-exterior-7q36-mkp5: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 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/inscripciones-electorales-en-el-exterior-7q36-mkp5" \
  --handler-options '{
    "domain": "www.datos.gov.co",
    "tables": {
        "inscripciones_electorales_en_el_exterior": "7q36-mkp5"
    }
}'

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/inscripciones-electorales-en-el-exterior-7q36-mkp5 is just another Postgres schema.