Giter VIP home page Giter VIP logo

schemainspect's Introduction

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.

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]

schemainspect's People

Contributors

djrobstep avatar maximsmol avatar alvarogzp avatar mshahbazi avatar gregplaysguitar avatar adamlthomas avatar jasongi-actu avatar etaoins avatar spoykko avatar trendels avatar bensjoberg avatar emilbayes avatar markottt avatar pauldraper avatar skoschik avatar stephen-page avatar tolmacevalexandr avatar kwargs avatar lazydba247 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.