Skip to content

Basic Setup

This recipe demonstrates the most basic configuration to get started with the plugin.

Configuration

In your mkdocs.yml:

plugins:
  - sqlalchemy:
      base_class: "basic_setup.models.Base"
      app_path: "src"

Usage

In your markdown file (e.g., index.md):

# MkDocs SqlAlchemy Plugin

{% sqlalchemy %}

This will generate documentation for all tables found in the basic_setup.models.Base metadata.


Result

Table: posts

column type nullable default primary_key unique foreign_key
id INTEGER ✔️
title VARCHAR(200)
content TEXT ✔️
is_published BOOLEAN ✔️ False
user_id INTEGER ✔️ users.id
created_at DATETIME ✔️ utcnow
updated_at DATETIME ✔️ utcnow

Indexes:

  • ix_posts_updated_at: updated_at

Constraints:

  • pk_posts (PrimaryKeyConstraint)
  • fk_posts_user_id_users (ForeignKeyConstraint)

Table: user_profiles

column type nullable default primary_key unique foreign_key
id INTEGER ✔️
user_id INTEGER ✔️ ✔️ users.id
first_name VARCHAR(50) ✔️
last_name VARCHAR(50) ✔️
bio TEXT ✔️

Indexes: None

Constraints:

  • uq_user_profiles_user_id (UniqueConstraint)
  • fk_user_profiles_user_id_users (ForeignKeyConstraint)
  • pk_user_profiles (PrimaryKeyConstraint)

Table: users

column type nullable default primary_key unique foreign_key
id INTEGER ✔️
username VARCHAR(50) ✔️
email VARCHAR(120) ✔️
is_active BOOLEAN ✔️ True
created_at DATETIME ✔️ utcnow

Indexes: None

Constraints:

  • uq_users_email (UniqueConstraint)
  • uq_users_username (UniqueConstraint)
  • pk_users (PrimaryKeyConstraint)