mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d
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 database_of_political_institutions_2015 table in this repository, by referencing it like:

"mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d:latest"."database_of_political_institutions_2015"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "gwno",
    "muni", -- Are municipal governments locally elected? 0 if neither local executive nor local legislature are locally elected. 1 if the executive is appointed, but the legislature elected. 2 if they are both locally elected. No information, or no evidence of municipal governments, is recorded as blank. If one source has information on a specific period, and the other has no information on a different period, we do not extrapolate from one source to another - no information is always recorded as blank. If there are multiple levels of sub-national government, we consider the lowest level as the “municipal” level. This variable was extensively updated for this version, and as a result, the number of non-missing observations has increased from 42% to 61%.
    "fraud", -- Were vote fraud or candidate intimidation serious enough to affect the outcome of elections? This variable captures extra-constitutional irregularities, which are recorded only if mentioned in sources. 0 reported for countries where, for example, opposition parties are officially and constitutionally banned or where irregularities are not mentioned (although may still exist); “1” when opposition is officially legal but suppressed anyway. If not an election year, or if elected government has been deposed, refers to most recent election (i.e. the only way to get rid of a “1” is to hold a fair election).
    "select", -- Candidate selection 1:National (by national executive, party leader, interest groups or party factions) 2: Sub-national (by subset of constituency party members e.g. on conventions) 3: Primary (including party primary and primaries using all the votes of a constituency) Blank if no information.
    "thresh", -- What is the vote threshold for representation? Records the minimum vote share that a party must obtain in order to take at least one seat in PR systems. If there are more than one threshold, record the one that governs the most seats. No information from sources results in a 0.
    "ssh", -- Number of senate/ (number of house + number of senate)
    "mdms", -- Mean District Magnitude (MDM), House and Senate
    "liec", -- Legislative IEC. Scale: No legislature: 1 Unelected legislature: 2 Elected, 1 candidate: 3 1 party, multiple candidates: 4 multiple parties are legal but only one party won seats: 5 multiple parties DID win seats but the largest party received more than 75% of the seats: 6 largest party got less than 75%: 7
    "exelec", -- “1” if there was an executive election in this year.
    "dateleg", -- Month when presidential/parliamentary elections were held. The numbers 1 to 12 denote the months from January to December when the election was held. 13 is marked if the month was not known. In the case of multiple elections during a year, we record the election immediately prior to the installment of a candidate in office. Thus runoffs are counted, but their prior elections are not. In cases that candidates take office after each of multiple elections, we record the month of the first round of elections that year.
    "ulvote", -- House non-aligned or independent - Vote Share
    "numul", -- House non-aligned or independent - Seats
    "ulprty", -- House non-aligned or independent - Number of parties
    "oppothvt", -- Other Opposition Parties - Total Vote Share
    "oppothst", -- Other Opposition Parties - Total Seats
    "oppoth", -- Other Opposition Parties - Number of Parties
    "opp3vote", -- 3rd OPP. PARTY - Vote Share
    "opp3seat", -- 3rd OPP. PARTY - Seats
    "opp3me", -- 3rd OPP. PARTY - Name
    "opp2seat", -- 2nd OPP. PARTY - Seats
    "opp2me", -- 2nd OPP. PARTY - Name
    "opp1age", -- LARGEST OPP. PARTY - Time since formation
    "opp1reg", -- LARGEST OPP. PARTY - Regional
    "opp1vote", -- LARGEST OPP. PARTY - Total Vote Share
    "opp1me", -- LARGEST OPP. PARTY - Name
    "govothst", -- Other GOVT. PARTIES - Total Seats
    "govoth", -- Other GOVT. PARTIES - Number of Parties
    "gov3vote", -- 3rd GOVT. PARTY - Vote Share
    "gov3seat", -- 3rd GOVT. PARTY - Seats
    "gov3me", -- 3rd GOVT. PARTY - Name
    "gov2rlc", -- 2nd GOVT. PARTY - R, L, C, 0, or NA
    "gov2vote", -- 2nd GOVT. PARTY - Vote Share
    "gov2me", -- 2nd GOVT. PARTY - Name
    "gov1age", -- LARGEST GOVT PARTY - Time since formation
    "gov1reg", -- LARGEST GOVT PARTY - Regional
    "gov1nat", -- LARGEST GOVT PARTY - Nationalist
    "gov1vote", -- LARGEST GOVT PARTY - Vote Share
    "gov1seat", -- LARGEST GOVT PARTY - Seats
    "gov1me", -- LARGEST GOVT PARTY - Name
    "totalseats", -- Total seats in the legislature, or in the case of bicameral legislatures, the total seats in the lower house. This variable includes appointed and elected seats and is calculated two ways: 1) in most cases it is calculated by adding the values for all the seat share variables (gov1seat, gov2seat, gov3seat, opp1seat, opp2seat, opp3seat, govothst, oppothst, numul); 2) it is entered by hand in cases where the seat share of some parties is not specified in the sources. Total seats is NA (-999) when there is no legislature or when the legislature had been dissolved.
    "nonchief", -- In systems with both non-ceremonial PM and President, what is the party affiliation of the one not called Chief Executive? For parliamentary systems (2 in SYSTEM) with non-ceremonial president: what is the party affiliation of the president? NA if the president is ceremonial or non-existent, or if SYSTEM has a score of 1 or 0.
    "execage", -- Time since formation under this name.NA if executive is not affiliated with a party. We record party age from the first year that the party was founded under its current name (which can be before a country achieves independence).
    "execrel", -- Religious (1:Christian, 2: Catholic, 3: Islamic, 4: Hindu, 5: Buddhist, 6: Jewish, 0: otherwise)
    "execreg", -- Regional (1 if yes) If our sources list regional issues as a key component of the party’s platform, or if a specific region or regions are a key party constituency, this variable is coded as “1”. Deviating from convention, 0 unless explicitly stated. In cases where executive is independent, the executive’s personal orientation is recorded. NA if no executive
    "execnat", -- Nationalist (1 if yes); 0 otherwise (deviating from convention). In cases where executive is independent, the executive’s personal orientation is recorded. NA if no executive
    "execrlc", -- Right (1); Left (3); Center (2); No information (0); No executive (NA)
    "execme", -- Name of party, if any “Independent” if the chief executive is independent, a monarch, in the military, or if there are no parties. Party orientation with respect to economic policy, coded based on the description of the party in the sources, using the following criteria: Right: for parties that are defined as conservative, Christian democratic, or right-wing. Left: for parties that are defined as communist, socialist, social democratic, or left-wing. Center: for parties that are defined as centrist or when party position can best be described as centrist (e.g. party advocates strengthening private enterprise in a social-liberal context). Not described as centrist if competing factions “average out” to a centrist position (e.g. a party of “right-wing Muslims and Beijing-oriented Marxists”). 0: for all those cases which do not fit into the above-mentioned category (i.e. party’s platform does not focus on economic issues, or there are competing wings), or no information. NA: for those cases which there is no executive.
    "percentl", -- President got what % of votes in the final round? NA for reasons above, or if no runoff. If not an election year, records most recent election.
    "percent1", -- President got what % of votes in the 1st/only round?  NA if SYSTEM gets a 1 or 2, and in the case of those with a 2 in Executive Index of Electoral Competition (see below for EIEC definition). If there is a prime minister who is considered the chief executive, but there is a president with some powers (e.g., France) then we still record the president’s vote %. If not an election year, records most recent election. If a vice president is completing a president’s term in office, he gets the same score as the former president. If a president is prevented from taking office and later returns without an election (but within the limits of his original term) he gets the same score as his original election.
    "system", -- Parliamentary (2), Assembly-elected President (1), Presidential (0), -999 not applicable
    "year",
    "countryname",
    "author", -- Do the state/provinces have authority over taxing, spending, or legislating? If 1 for any of these, category gets a 1. Authority over “cultural affairs”, or “planning” in Communist systems, does not qualify. This variable was extensively updated for this version, and as a result, the number of non-missing observations has increased from 38% to 42%.
    "opp2vote", -- 2nd OPP. PARTY - Vote Share
    "gov2age", -- 2nd GOVT. PARTY - Time since formation
    "allhouse", -- Does the party of the executive have an absolute majority in the houses that have lawmaking powers? The case of an appointed Senate is considered as controlled by the executive. A senate made up along the lines of ethnic or tribal representation is not controlled by the executive, as these groups nominate their own representatives.
    "yrsoffc", -- How many years has the chief executive been in office?
    "ifs",
    "stconst", -- Are the constituencies of the senators the states/provinces? No information recorded as blank. If no senate or no states/provinces, NA. If the senate is only partially elected through the constituencies, we score according to how the majority is elected. If the senate is appointed or elected on a national basis, this gets a 0.
    "auton", -- Are there autonomous regions? Autonomous regions are not the same as states, provinces, etc. An autonomous region is recorded if a source explicitly mentions a region, area, or district that is autonomous or self-governing. Furthermore, they must be constitutionally designated as “autonomous” or “independent” or “special”. Federal Districts or Capital Districts do not count as autonomous regions. Disputed autonomy is not recorded. Indian reservations are not counted as autonomous. Deviating from convention, no information recorded as 0.
    "gov2rel", -- 2nd GOVT. PARTY - Religious
    "gov1rurl", -- LARGEST GOVT PARTY - Rural
    "gov1rlc", -- LARGEST GOVT PARTY - R, L, C, 0, or NA
    "execrurl", -- Rural (1 if yes); constituency, this variable is coded as “1”. Deviating from convention, 0 unless explicitly stated. In cases where executive is independent, the executive’s personal orientation is recorded. NA if no executive.
    "prtyin", -- Party of chief executive has been how long in office Same rules as YRSOFFC. NA if there are no parties, if the chief executive is an independent, or if the “party” is the army. In general, the counting restarts from 1 for a party if its name changes. However, in a few cases the sources indicated that party leadership, membership, and platform remained the same following the name change. In these cases, the name change was recorded but the year count did not restart. All of these cases are noted in the database.
    "defmin", -- Is defense minister a military officer? Same as in MILITARY. If no one in the cabinet with such responsibility, or if there are no armed forces, then “NA”. If there is no defense minister but the chief executive controls military directly, then same answer as in MILITARY.
    "military", -- Is Chief Executive a military officer? "1" if the source (Europa or Banks) includes a rank in their title; 0 otherwise.
    "yrcurnt", -- Year left in current term. Only full years are counted. Thus, a “0” is scored in an election year, and n-1 in the year after an election, where n is the length of the term.
    "finittrm", -- Is there a finite term in office? (1 if yes, 0 if no, -999 not applicable)
    "location_1_zip",
    "location_1_address",
    ":@computed_region_gpzg_6ssq",
    "location_1_state",
    "location_1_city",
    "dhondt", -- Is the D'Hondt system used? (1 if yes, 0 if no) Is the D’Hondt rule used to allocate seats in a PR system? NA if PR is 0 or NA. If PR is 1, and information is only available from IPU, just record data in 1995.
    "mdmh", -- Mean District Magnitude (MDM), House and Senate
    "opp1seat", -- LARGEST OPP. PARTY - Seats
    "govothvt", -- Other GOVT. PARTIES - Total Vote Share
    "gov3age", -- Time since formation
    "multpl", -- If there are formal restraints on  an executive's term (NA if not), can s/he serve additional term(s) following the current one?
    "gov2seat", -- 2nd GOVT. PARTY - Seats
    "gov2nat", -- 2nd GOVT. PARTY - Nationalist
    "gov3reg", -- 3rd GOVT. PARTY - Regional
    "opp1rel", -- LARGEST OPP. PARTY - Religious
    "dateexec", -- Month when presidential/parliamentary elections were held. The numbers 1 to 12 denote the months from January to December when the election was held. 13 is marked if the month was not known. In the case of multiple elections during a year, we record the election immediately prior to the installment of a candidate in office. Thus runoffs are counted, but their prior elections are not. In cases that candidates take office after each of multiple elections, we record the month of the first round of elections that year.
    "gov2rurl", -- 2nd GOVT. PARTY - Rural
    "opp1rurl", -- LARGEST OPP. PARTY - Rural
    "legelec", -- “1” if there was a legislative election in this year.
    "location_1",
    "gov1rel", -- LARGEST GOVT PARTY - Religious
    "gov3rlc", -- 3rd GOVT. PARTY - R, L, C, 0, or NA
    "gov3nat", -- 3rd GOVT. PARTY - Nationalist
    "gov3rurl", -- 3rd GOVT. PARTY - Rural
    "gov3rel", -- 3rd GOVT. PARTY - Religious
    "gov2reg", -- 2nd GOVT. PARTY - Regional
    "opp1nat", -- LARGEST OPP. PARTY - Nationalist
    "opp1rlc", -- LARGEST OPP. PARTY - R, L, C, 0, or NA
    "pluralty", -- Plurality? (1 if yes, O if no)
    "oppmajh", -- Does one opposition party have an absolute majority in House? NA if no House
    "eiec", -- Executive IEC. Uses same scale as Legislative IEC
    "pr", -- Proportional Representation? (1 if yes, 0 if no)
    "housesys", -- Which electoral rule (proportional representation or plurality) governs the election of the majority of House seats? This is coded 1 if most seats are Plurality, zero if most seats are Proportional. In cases where the majority of legislators are appointed or indirectly elected, HOUSESYS is coded Indirect.
    "cl", -- Are closed lists used? (1 if yes, O if no)
    "oppmajs" -- Senate: Does one opposition party have absolute majority in Senate? NA if no Senate, or if Senate is neither appointed nor based on parties (based instead on tribal chiefs, professional representatives, etc.).
FROM
    "mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d:latest"."database_of_political_institutions_2015"
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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d 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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d: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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d

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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d:latest

This will download all the objects for the latest tag of mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d 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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d: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 mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d: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, mydata-iadb/database-of-political-institutions-2015-ngy5-9h9d is just another Postgres schema.

Related Documentation:

Loading...