schemainspect
Schema inspection for PostgreSQL (and possibly others)
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 schemainspectuv
uv add schemainspectpoetry
poetry add schemainspectInstalling 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
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
sqlalchemy-diffCompares database schemas across two…
permissive · top 15,000 on PyPI
alembic_utilsExtends Alembic to autogenerate database…
permissive · top 5,000 on PyPI
migramigra compares PostgreSQL database schemas and…
permissive · top 15,000 on PyPI
sqlalchemy-viewsAdds CreateView and DropView SQL constructs to…
permissive · top 15,000 on PyPI
django-pgviews-reduxAdds first-class PostgreSQL view support to…
unclear · top 15,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
pglastParses PostgreSQL SQL statements into an…
copyleft · top 5,000 on PyPI
sqlacodegenReads an existing database schema and generates…
permissive · top 5,000 on PyPI
django-postgres-extraExtends Django's ORM to expose…
permissive · top 15,000 on PyPI
django-tenantsEnables Django applications to serve multiple…
permissive · top 5,000 on PyPI