Schema Inspect is a Python library for programmatically inspecting database schemas, with a strong focus on PostgreSQL. It integrates with SQLAlchemy to provide a structured representation of tables, columns, constraints, and other schema objects. The current version is 3.1.1663587362, which uses a unique timestamp-based versioning scheme, reflecting its last significant update in late 2022.
pip install schemainspectVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to connect to a database using a DSN (Data Source Name) and use `schemainspect` to retrieve and print the names of all tables and basic column details from the inspected schema. It uses an environment variable for the DSN for security.
Always test `schemainspect` thoroughly after updating, especially if relying on specific schema inspection behaviors.
Thoroughly test schema inspection results if using a database other than PostgreSQL. Refer to SQLAlchemy's dialect documentation for specifics of your chosen database.
Explicitly check for view types if your database contains views and you need to inspect them. For advanced view introspection, consider using database-specific tools or raw SQLAlchemy reflection if `schemainspect` provides insufficient detail.