Aller au contenu
Skillpedia
Bases de données18k · #10727

generate-mdl

Ce qu’il fait

Cette skill guide la création d'un projet MDL Wren à partir d'une base de données existante, notamment la découverte du schéma, le nettoyage des types et la génération de YAML avec la ligne de commande wren. Elle s'adresse aux analystes qui veulent mettre en place une couche sémantique sur une base qu'ils utilisent déjà.

Quand l’utiliser

  • ✓Quand vous voulez créer un nouveau projet Wren pour une base de données que vous possédez déjà.
  • ✓Quand votre équipe répertorie déjà la base dans OpenMetadata et que vous voulez l'importer.
  • ✓Quand vous avez besoin de générer un projet sémantique à partir de tables existantes et de leurs relations.

Lien du skill

https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Crée un projet Wren à partir de notre base de données de ventes Postgres, en déduisant les relations entre les tables et en vérifiant que le projet se construit.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

La skill demande à votre agent de lire le schéma avec ses outils de base de données, de normaliser les types de données, de générer les fichiers du projet avec la CLI wren et de valider la construction.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

Generate Wren MDL — CLI Agent Workflow

Builds an MDL project by discovering database schema and converting it into Wren's YAML project format. The agent uses whatever database tools are available in its environment for introspection; the wren CLI handles type normalization, validation, and build.

For memory and query workflows after setup, run wren skills get usage.

Prerequisites

  • wren CLI installed (pip install "wrenai[<datasource>]")
  • A working database connection (credentials available to the agent)
  • A connection profile (set up via wren profile add) or connection info ready

Alternative — import from an OpenMetadata catalog

If the user's team already catalogs this database in OpenMetadata, import from the catalog instead of introspecting the live database. The import carries curated table/column descriptions, tags, owners, and foreign-key constraints (as relationships.yml), so the join-inference work in Phase 4 is mostly done:

wren context import openmetadata --host <om_url> --token <om_token> \
  --service <om_service> --database <db> --schema <schema> --dry-run
wren context import openmetadata --host <om_url> --token <om_token> \
  --service <om_service> --database <db> --schema <schema>

Ask the user for the OpenMetadata URL, a read-only bot or personal access token, and the service name as it appears in OpenMetadata. --table (repeatable) narrows the import. Without --force the command only adds files that do not exist and lists the collisions it left untouched; --force regenerates from OpenMetadata and discards local edits to generated files — confirm with the user before using it. Relationships come from foreign keys only; review whether additional joins are needed (Phase 4), then bind a profile and finish with Phase 5 (wren context validate → wren context build).

Phase 0 — Detect existing project

Goal: If the current directory is already inside a wren project, let the user decide how to proceed.

Check whether wren_project.yml exists in the current working directory (or any parent up to the repository root). If found:

  1. Tell the user that an existing wren project was detected and show its path.
  2. Ask:
    • Reset — wipe the existing project (models/, views/, relationships.yml, knowledge/, and rebuild wren_project.yml) and regenerate from scratch in the same directory.
    • New path — keep the existing project untouched and choose a different directory for the new project. Ask the user for the new path, then wren context init --path <new_path> and continue from Phase 1 using that path.

If no existing project is detected, proceed directly to Phase 1.

Phase 1 — Establish connection and scope

Goal: Confirm the agent can reach the database and agree on scope with the user.

  1. Verify connectivity using whichever tool is available:

    • If SQLAlchemy: engine.connect() test
    • If database driver: simple query like SELECT 1
    • If wren profile exists: wren profile debug to check config
    • If raw SQL via wren: wren --sql "SELECT 1" (requires profile or connection file)
  2. Ask the user:

    • Which schema(s) or dataset(s) to include (skip if only one exists)
    • Whether to include all tables or a subset
    • The datasource type for wren (e.g., postgres (including Aurora), mysql (including Aurora), bigquery, snowflake) — needed for type normalization dialect

Phase 2 — Discover schema

Goal: Collect table names, column names, column types, and constraints.

Use whatever introspection method is available. Here are common approaches ranked by convenience:

Option A: SQLAlchemy (recommended if available)

from sqlalchemy import create_engine, inspect

engine = create_engine(connection_url)
inspector = inspect(engine)

tables = inspector.get_table_names(schema="public")

for table in tables:
    columns = inspector.get_columns(table, schema="public")
    # columns → [{"name": "id", "type": INTEGER(), "nullable": False, ...}]

    pk = inspector.get_pk_constraint(table, schema="public")
    # pk → {"constrained_columns": ["id"], "name": "orders_pkey"}

    fks = inspector.get_foreign_keys(table, schema="public")
    # fks → [{"constrained_columns": ["customer_id"],
    #          "referred_table": "customers",
    #          "referred_columns": ["id"]}]

Option B: Database-specific driver

  • psycopg / asyncpg (Postgres): Query `informatio
Questions fréquentes

Qu'est-ce que MDL ?

C'est le format de modèle sémantique utilisé par Wren pour décrire les tables, les colonnes et les relations en YAML simple.

Peut-on importer depuis un catalogue de données ?

Oui. La skill décrit l'import depuis OpenMetadata, qui transfère les descriptions et les clés étrangères dans le projet.

Faut-il des identifiants de base de données ?

Oui. Votre agent a besoin d'une connexion fonctionnelle et d'identifiants disponibles dans son environnement pour lire le schéma.

Détails

Description originale de l’auteur

Generate a Wren MDL project by exploring a database with available tools (SQLAlchemy, database drivers, MCP connectors, or raw SQL). Guides agents through schema discovery, type normalization, and MDL YAML generation using the wren CLI. Use when: user wants to create or set up a new MDL, onboard a new data source, or scaffold a project from an existing database.

repo: Canner/WrenAI

Popularité

Étoiles GitHub
18k
Position au classement
#10727
Licence
—
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires