Skip to main content

schemainspect: SQL Schema Inspection

Schema inspection for PostgreSQL (and potentially others in the future).

Inspects tables, views, materialized views, constraints, indexes, sequences, enums, functions, and extensions. Handles table partitioning and inheritance.

Limitations: Function inspection only confirmed to work with SQL/PLPGSQL languages so far.

Installing

Cogna publishes this fork to PyPI as cogna-schemainspect. It installs the same top-level schemainspect package as schemainspect and schema-inspect-maintained, so installing it alongside either one overwrites files, and uninstalling one breaks the other. Uninstall them first:

pip uninstall schemainspect schema-inspect-maintained
pip install cogna-schemainspect

For a schema diff tool built on it, install cogna-migra rather than upstream migra, which depends on upstream schemainspect.

Basic Usage

Get an inspection object from an already opened SQLAlchemy session or connection as follows:

from schemainspect import get_inspector
from sqlbag import S

with S('postgresql:///example') as s:
    i = get_inspector(s)

The inspection object has attributes for tables, views, and all the other things it tracks. At each of these attributes you'll find a dictionary (OrderedDict) mapping from fully-qualified-and-quoted-name-of-thing-in-database to information object.

For instance, the information about a table books would be accessed as follows:

>>> books_table = i.tables['"public"."books"']
>>> books_table.name
'books'
>>> books_table.schema
'public'
>>> [each.name for each in books_table.columns]
['id', 'title', 'isbn']

Documentation

Documentation is a bit patchy at the moment. Watch this space!

Author Credits

Initial development, maintenance:

Contributions:

Install

Install with pip:

$ pip install schemainspect

To install psycopg2 (the PostgreSQL driver) at the same time as well:

$ pip install schemainspect[pg]

Metadata

Release files for cogna-schemainspect 1.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cogna-schemainspect 1.2.4
File Size Uploaded Provenance Actions
cogna_schemainspect-1.2.4.tar.gz 31.7 kB With provenance Details for cogna_schemainspect-1.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cogna-schemainspect 1.2.4
File Interpreter ABI Platform Actions
cogna_schemainspect-1.2.4-py3-none-any.whl Python 3 none any Details for cogna_schemainspect-1.2.4-py3-none-any.whl

Total release size: 74.9 kB

Release files / cogna_schemainspect-1.2.4.tar.gz

Download URL cogna_schemainspect-1.2.4.tar.gz
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d9fed226ae9ac48b6889396fdc89ddd1e5435edd6262b683d67d53bfec876b10
BLAKE2b-256 checksum
How to use checksums
8dae9caaed86c8910e9d3f296134d6ca1bff40cf5fd5fa01a814820f86ecdea3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / cogna_schemainspect-1.2.4-py3-none-any.whl

Download URL cogna_schemainspect-1.2.4-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5783bc19a5b0b103a73b1f54430298ee04ef6596d301301775206ffda2baa2d
BLAKE2b-256 checksum
How to use checksums
1a0d49bc028a5f188022cecaa63c15b2d1f8dae6d4bb3d8cfed7fd2f3fd68666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for cogna-schemainspect 1.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cogna_schemainspect-1.2.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.4 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page