Schema inspection for PostgreSQL (and possibly others)
Project description
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.
Limitations: Function inspection only confirmed to work with SQL/PLPGSQL languages so far.
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]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for schemainspect-0.1.1540897086.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45aee35ac9c7ac338ee380502e4d49d2d086a1b97b4788fdca165d0f23b11f5 |
|
MD5 | ba95676a0441f24bb8ec02435c489ef2 |
|
BLAKE2b-256 | fcab964e7a956b73de6100b2ceb0fe6b05d570c5854e5d41fc4c7a4c41ce79db |
Hashes for schemainspect-0.1.1540897086-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f905a15a9631331b93f716b1af0f68ab950b2845819dc26d33cdf36f6414193 |
|
MD5 | 41b2eb18c8abbf2b5e4a61324ea3c3a7 |
|
BLAKE2b-256 | b80f8a31022e5840893f41816f160cc8a37c74e4d13b3f996f6fe8bc210327aa |