Skip to main content

SqlAlchemy schema display script

Project description

.. -*- restructuredtext -*-

=========
sadisplay
=========

About
=====
Simple package for describing SQLAlchemy schema and display raw database
tables. Relation detecting by `ForeignKey` columns.
Supports mapped class inherit. BSD licensed.


Output formats:

* `PlantUML <http://plantuml.sourceforge.net/>`_ class diagram
* `DOT <http://www.graphviz.org/>`_ graphviz directed graphs


Requirements
============
* python >= 2.5
* SQLAlchemy >= 0.5


Install
=======

::

pip install sadisplay

From bitbucket::

pip install http://bitbucket.org/estin/sadisplay/get/tip.tar.gz
# or
easy_install http://bitbucket.org/estin/sadisplay/get/tip.tar.gz


Usage
=====

SQLAlchemy model:

.. include:: examples/e01.py
:literal:


Write simple script in your project environment::

import sadisplay
from yourapp import model

desc = sadisplay.describe([getattr(model, attr) for attr in dir(model)])
open('schema.plantuml', 'w').write(sadisplay.plantuml(desc))
open('schema.dot', 'w').write(sadisplay.dot(desc))

# Or only part of schema
desc = sadisplay.describe([model.User, model.Group, model.Persmission])
open('auth.plantuml', 'w').write(sadisplay.plantuml(desc))
open('auth.dot', 'w').write(sadisplay.dot(desc))


Render PlantUML class diagram::

$ java -jar plantuml.jar schema.plantuml

# or for svg format
$ java -jar plantuml.jar -Tsvg schema.plantuml


Render graph by graphviz::

$ dot -Tpng schema.dot > schema.png


Also you can display you sql database tables by reflecting feature::

$ sadisplay -u <URL connection string to db> -r dot > schema.dot
$ dot -Tpng schema.dot > schema.png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sadisplay-0.3.9dev.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

sadisplay-0.3.9dev-py2.py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page