Skip to main content

Run SQL queries against Wikidata by translating them to SPARQL

Project description

Wikidata-SQL

Run SQL queries against Wikidata. Instead of writing SPARQL, write familiar SQL using Wikidata Q-IDs as table names.

Quick Start

pip install -e .
wikisql

How It Works

A Q-ID in the FROM clause creates a virtual table of all entities with that class:

-- All Shinto shrines (instances of Q845945)
SELECT * FROM Q845945 LIMIT 10;

This translates to:

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q845945 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
LIMIT 10

Custom Properties

By default, FROM Q... uses P31 (instance of). Prefix with a property to change this:

-- Subclasses of Shinto shrine
SELECT * FROM P279:Q845945 LIMIT 10;

Usage

Interactive REPL:

wikisql

Single query:

wikisql "SELECT * FROM Q845945 LIMIT 10"

Show generated SPARQL:

wikisql --sparql "SELECT * FROM Q845945 LIMIT 10"

Change label language:

wikisql -l ja "SELECT * FROM Q845945 LIMIT 10"

REPL Commands

  • \sparql - Toggle SPARQL display on/off
  • \q / quit / exit - Exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wikisql-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wikisql-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file wikisql-0.1.0.tar.gz.

File metadata

  • Download URL: wikisql-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wikisql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96ee5f1007ddf57ac20d371a4b20d824f09cffb2e8a7b3b884d8d406fcec9626
MD5 bf6aae65ef0b015857cc1f69b5eb9f75
BLAKE2b-256 db472b771f784baaeed3daac211dcced93913f4c91128161d2b863faf9b7020d

See more details on using hashes here.

Provenance

The following attestation bundles were made for wikisql-0.1.0.tar.gz:

Publisher: workflow.yml on Emma-Leonhart/WikiSQL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wikisql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wikisql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wikisql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b977cbac771a8ad2c254db0cc5849fd138d677ccd5a56c56b4e45e4fe47142e7
MD5 a3a9a545a441e8ce34164f362ce5026b
BLAKE2b-256 3a16cbcca8d0aa9f684eadc65bb3e5272dd4a5245c56fb50e77db9985bbe9515

See more details on using hashes here.

Provenance

The following attestation bundles were made for wikisql-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on Emma-Leonhart/WikiSQL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page