skillfed

schemainspect

Schema inspection for PostgreSQL (and possibly others)

schemainspect v3.1.1663587362 247.9K downloads/30d#8,680 on PyPI53
Permissive license Unlicense DORMANT released

What it is and what it does

Schemainspect is a Python library that reads the structure of a PostgreSQL database and exposes it as Python objects through a SQLAlchemy connection. It introspects tables, views, materialized views, constraints, indexes, sequences, enums, functions, and extensions, including support for table partitioning and inheritance. You pass it an open SQLAlchemy session or connection and receive an inspector object with dictionary-like attributes mapping fully-qualified database object names to information objects.

The library is designed for developers who need programmatic access to database schema metadata—for instance, to generate documentation, validate schema changes, or build schema-aware tools. It depends only on sqlalchemy and installs with low friction. The package is dormant but stable; it has no known vulnerabilities and supports Python 3.7 through 3.10.

Use it for:

  • Extract table and column metadata from a PostgreSQL database to generate schema documentation or diagrams.
  • Validate database schema changes by comparing inspector snapshots before and after migrations.
  • Build schema-aware code generators or ORM mappers that need to introspect the live database structure.
  • Audit database objects like functions, constraints, and indexes programmatically in a Python application.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Inspects PostgreSQL database schemas to extract metadata about tables, views, indexes, constraints, functions, and other database objects through a SQLAlchemy connection.

Yes, if you need to inspect a PostgreSQL schema programmatically. The package is dormant but stable, has no vulnerabilities, and installs cleanly with only sqlalchemy as a dependency. The main caveat is that it is no longer actively maintained; if you encounter bugs or need support for new PostgreSQL features, you may need to fork or patch it yourself.

Install

schemainspect on PyPI

pip

pip install schemainspect

uv

uv add schemainspect

poetry

poetry add schemainspect

Installing schemainspect

Before you install

Low install friction with a single runtime dependency on sqlalchemy. The package is dormant (last release 2022-09-19, last commit 2024-05-14), so maintenance is not active, but the repository remains public and unarchived.

License in practice

Licensed under the Unlicense (permissive), which places the work in the public domain with minimal restrictions on use or modification.

Quickstart

from schemainspect import get_inspector
from sqlalchemy import create_engine

engine = create_engine('postgresql://user:password@localhost/dbname')
with engine.connect() as conn:
    inspector = get_inspector(conn)
    books = inspector.tables['"public"."books"']
    print(books.name, [col.name for col in books.columns])

Requires a running PostgreSQL database and a valid connection string; psycopg2 (PostgreSQL driver) must be installed separately or via the [pg] extra.

Verify before relying

  • Whether function inspection works reliably with languages other than SQL/PLPGSQL despite the stated limitation.
  • Current state of support for database systems other than PostgreSQL, given the 'potentially others in the future' language in the description.

Package facts

License Unlicense (permissive)
Python support supports the current Python release (>=3.7,<4)
Install friction low — pure-Python wheel
Runtime dependencies 1 — sqlalchemy
Maintenance dormant — 1,425 days since the last release
Last repo commit
First released
Downloads 247,944/month — #8,680 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: schemainspect-3.1.1663587362-py3-none-any.whl

License :: Other/Proprietary LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

postgresql schema inspectiondatabase metadata extractionsql schema analysistable structure introspectionpostgres schema explorer
schema-introspectionpostgresql

More Database packages