sphinx-sqlalchemy

Sphinx extension for documenting SQLAlchemy ORMs.

Usage

Install sphinx_sqlalchemy:

pip install sphinx_sqlalchemy

Add sphinx_sqlalchemy to your conf.py:

extensions = [
    'sphinx_sqlalchemy',
]

Example

.. sqla-model:: sqla_models.User

.. sqla-model:: ~sqla_models.Address
sqla_models.User (dbusers)

A user.

Columns:

pk*

INTEGER

first_name

VARCHAR?

The name of the user.

last_name

VARCHAR(255)?

The surname of the user.

dob

DATE

The date of birth.

Constraints:

  • PRIMARY KEY (pk)

  • UNIQUE (first_name, last_name)

Address (addresses)

An address.

Columns:

pk*

INTEGER

number

INTEGER

The number of the address.

postcode

VARCHAR

The postcode of the address.

→ user_id

INTEGER?

Constraints:

  • CHECK (number>0)

  • FOREIGN KEY (dbusers.pk → user_id)

  • PRIMARY KEY (pk)

Indexes:

  • ix_addresses_postcode (postcode)