Logo von Wikimedia Database

Wikimedia Database

Community
fuzheado
wikimedia-database

Execute SQL queries against Wikipedia database replicas (enwiki, wikidata, commonswiki) via an SSH tunnel to Toolforge, with connection management and data handling guardrails

Übersicht

Herausgeberfuzheado
RepositoryWikipedia-AI-Skills
Skill-Namewikimedia-database
Sterne
27
Forks
10
Mitgelieferte Dateien
7
LizenzMIT
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • 7 mitgelieferte Dateien

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von fuzheado auf GitHub veröffentlicht. Prüfen Sie den Quellinhalt vor der Installation.

Installation

Installieren Sie den KI-Skill Wikimedia Database in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner — liest SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-database
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill anlegen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format lesen kann, kann diesen Skill nutzen — kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikimedia-database .claude/skills/wikimedia-database
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Wikimedia Database in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Wikimedia Database automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Wikimedia Database nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Keys.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

⚠️ User-Agent required: While this skill primarily uses SQL via SSH tunnel, any direct API calls (e.g., for verification via curl or requests) must include a descriptive User-Agent header. See the wikimedia-api-access skill for the correct format.

Enables the agent to execute dynamic SQL queries against Wikimedia production replicas (e.g., enwiki, enwiki_p, wikidata, commonswiki) by leveraging a local SSH tunnel and specific environment variables for multi-layer authentication.

⚠️ Commons links tables moved to a separate cluster (x4) on 2026-09-08. The links tables on commonswiki (categorylinks, pagelinks, templatelinks, imagelinks, globalimagelinks, linktarget, externallinks, iwlinks, langlinks, existencelinks, collation) are no longer on the core cluster. Connect to links.commonswiki.analytics.db.svc.wikimedia.cloud for those tables, and join them to page / redirect / revision in application code — cross-cluster JOINs are not possible. The old copies on the core cluster are no longer updated, so any query still hitting them silently returns stale data. Table/column names are unchanged, and page + redirect remain available on both clusters. Since 2026-09-14 the x4 section is exposed on the Wiki Replicas, so the links hostnames return fresh data again (the s4 copies are no longer reachable from the replicas). Details: News/2026 Commons links tables database split and references/schema-replicas.md (hostname mapping + code-side join pattern).

Prerequisites

  • Authentication: The following variables must be set in the .env file:

  • TOOLFORGE_USER: The shell/LDAP username for SSH (e.g., janesmith).

  • TOOLFORGE_SQL_USER: The replica database username (e.g., u1234).

  • TOOLFORGE_SQL_PASSWORD: The replica database password.

  • TOOLFORGE_DB_PORT: The local port for the SSH tunnel (default: 3307). Set if you need a different port to avoid conflicts with a local MySQL/MariaDB instance.

  • SSH Config: The user must have their SSH keys added to the ssh-agent to allow non-interactive connections.

Standard Operating Procedure (SOP)

1. Connection Management

Before executing any SQL, the agent must ensure the tunnel is active.

  • Check: Attempt a connection to 127.0.0.1:${TOOLFORGE_DB_PORT:-3307}.
  • Auto-Establish: If the port is closed, the agent should attempt to spawn a background SSH process: ssh -L ${TOOLFORGE_DB_PORT:-3307}:enwiki.analytics.db.svc.wikimedia.cloud:3306 ${TOOLFORGE_USER}@login.toolforge.org -N
  • Persistence (Recommended): For long-running data generation, use autossh instead of plain ssh. Autossh monitors the connection and re-establishes it if the tunnel drops, which happens frequently during multi-hour sessions. Install with brew install autossh (macOS) or apt install autossh (Linux), then use: autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -L ${TOOLFORGE_DB_PORT:-3307}:enwiki.analytics.db.svc.wikimedia.cloud:3306 ${TOOLFORGE_USER}@login.toolforge.org -N -v
  • Escalation: If the tunnel fails to open, provide the user with the command above to run manually.

2. Implementation Pattern (Python)

The agent should use pymysql to interact with the replicas.

python
import os
import socket
import subprocess
import pymysql
from dotenv import load_dotenv

load_dotenv()

def get_db_connection(db_name='enwiki_p'):
    host = '127.0.0.1'
    port = int(os.getenv('TOOLFORGE_DB_PORT', '3307'))
    
    # Check if tunnel is open
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.settimeout(1)
        if s.connect_ex((host, port)) != 0:
            user = os.getenv("TOOLFORGE_USER")
            # Spawn persistent background tunnel
            cmd = ["ssh", "-L", f"{port}:enwiki.analytics.db.svc.wikimedia.cloud:3306", f"{user}@login.toolforge.org", "-N"]
            subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            
    return pymysql.connect(
        host=host,
        port=port,
        user=os.getenv("TOOLFORGE_SQL_USER"),
        password=os.getenv("TOOLFORGE_SQL_PASSWORD"),
        database=db_name,
        cursorclass=pymysql.cursors.DictCursor,
        charset='utf8mb4'
    )

def query_wiki(sql, db='enwiki_p'):
    conn = get_db_connection(db)
    try:
        with conn.cursor() as cursor:
            cursor.execute(sql)
            return cursor.fetchall()
    finally:
        conn.close()

3. Data Handling Guardrails

  • Read-Only: Only generate SELECT statements.
  • Namespace Filtering: Always consider page_namespace (e.g., 0 for Main/Article space).
  • Binary Decoding: Many strings (titles, user names) are stored as Varbinary. If the output looks like b'Title', the agent must apply .decode('utf-8').
  • Safety Limits: Every exploratory query must include a LIMIT (suggested default: 10-50).
  • Database Naming: Project names must end in _p (e.g., wikidatawiki_p, commonswiki_p).

MySQL 9+ compatibility

If you get ERROR 2059: Authentication plugin 'mysql_native_password' cannot be loaded when using the mysql CLI, this is because MySQL 9.x removed the mysql_native_password plugin entirely from the client — both as a loadable .so and as a compiled-in implementation. Neither --default-auth nor any other flag can work around this.

The fix is to use pymysql (pure Python). It implements the MySQL protocol natively and handles mysql_native_password authentication without any external plugins:

bash
pip install pymysql python-dotenv

The query.sh script will automatically use pymysql if available, falling back to the mysql CLI only if Python dependencies are missing.

Example Use Cases

  • Prompt: "What are the 5 oldest pages in the 'Draft' namespace?"

  • Action: Execute SELECT page_title, page_touched FROM page WHERE page_namespace = 118 ORDER BY page_id ASC LIMIT 5;

  • Prompt: "Count revisions by 'ExampleUser' on enwiki."

  • Action: Execute SELECT COUNT(*) FROM revision_userindex JOIN actor ON rev_actor = actor_id WHERE actor_name = 'ExampleUser';

  • Prompt: "Search edit summaries mentioning 'revert' by a specific user."

  • Action: Execute constrained SQL — the comment table has no full-text index, so queries MUST include both actor_name and rev_timestamp filters to avoid timeouts. See references/edit-summary-search.md for the full guide to edit-summary search across all approaches (SQL, Sigma tool, XML dumps, EventStreams).


Tooling

This skill includes helper scripts, reference docs, and templates:

🔧 Tunnel Management (scripts/setup-tunnel.sh)

Establishes an SSH tunnel to Toolforge. Auto-detects if tunnel is already active, prefers autossh for auto-reconnecting, and verifies the connection.

bash
./scripts/setup-tunnel.sh --yes                    # defaults
./scripts/setup-tunnel.sh [db_host] [local_port]

Refuses to run with no arguments: its default action is to background a long-lived SSH tunnel, so that has to be requested. Use --yes for the defaults.

Requires: TOOLFORGE_USER environment variable and SSH key loaded in agent.

🔧 Query Runner (scripts/query.sh)

Run a SQL query against a replica and see results in the terminal.

bash
./scripts/query.sh "SELECT page_title, page_len FROM page LIMIT 10" [database]

Includes safety guardrails: only SELECT allowed, missing env vars detected.

🔧 Tunnel Closer (scripts/close-tunnel.sh)

Cleanly tear down the SSH tunnel.

bash
./scripts/close-tunnel.sh [local_port]

📚 Schema Reference (references/schema-replicas.md)

Full reference of Wikimedia replica database tables (page, revision, actor, page_props, categorylinks, pagelinks) with column descriptions and common queries.

📚 Edit Summary Search (references/edit-summary-search.md)

Comprehensive guide to searching Wikipedia edit summaries. Covers the comment table indexing gap, constrained SQL patterns, the Σ (Sigma) Toolforge tool, XML dump processing, and EventStreams filtering. Load this when the task involves finding edits by their summary text.

📚 Connection Guide (references/connection-guide.md)

Step-by-step guide for setting up Toolforge access, getting credentials, and troubleshooting common issues.

🧩 Environment Template (assets/.env.example)

bash
cp assets/.env.example .env
# Edit .env with your credentials

🧩 Sample SQL Queries (assets/sample-queries.sql)

50+ pre-built SQL queries organized by category (page info, stats, categories, pageviews, Wikidata, revisions, links, cross-refs, user activity).


Cross-References

Related SkillWhy
wikimedia-toolforgeSSH tunnel setup and Toolforge access
wikimedia-page-assessmentPageAssessments queries use the same database connection pattern
wikimedia-pageviewsPageview SQL queries via page_props table
wikimedia-api-accessUser-Agent format for any follow-up API calls

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Wikimedia Database?

Execute SQL queries against Wikipedia database replicas (enwiki, wikidata, commonswiki) via an SSH tunnel to Toolforge, with connection management and data handling guardrails

Warum Wikimedia Database in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Wikimedia Database besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Wikimedia Database in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-database ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Wikimedia Database nutzen?

Jedes Modell, das Sie in TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Wikimedia Database verwenden?

So viele Sie möchten. Solange ein Modell Skills unterstützt, können Sie Wikimedia Database damit verwenden – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama und weitere – alles in TypingMind mit Ihren eigenen API-Schlüsseln.

Ist der KI-Skill Wikimedia Database kostenlos?

Ja. Der Skill wird von fuzheado auf GitHub unter der Lizenz MIT veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: eine Datei namens SKILL.md mit einem Namen und einer Beschreibung sowie allen Skripten, Vorlagen oder Referenzdateien, die das Modell möglicherweise benötigt. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und benötigen daher weder Server noch API-Schlüssel oder Laufzeitumgebung. Sie funktionieren mit jedem Modell.

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇