An open API service indexing awesome lists of open source software.

https://github.com/sphinx-contrib/sqlalchemyviz

SqlAlchemyViz Sphinx Extension
https://github.com/sphinx-contrib/sqlalchemyviz

Last synced: 1 day ago
JSON representation

SqlAlchemyViz Sphinx Extension

Awesome Lists containing this project

README

        

SQLAlchemyViz Sphinx Extension
==============================

This file provides a Sphinx extension to include an Entity-Relationship
diagram of SQLAlchemy metadata, generated by the
`SQLAlchemyViz `_ package. This is
a highly unpolished extension which does almost no heavy lifting, and not
portable across platforms. The SQLALchemyViz package converts the SQLAlchemy
metadata object into a dot file. The extension then uses POSIX/Linux tools
via python's subprocess mechanisms to improve the layout of the graph.

To achieve the same effect directly from the shell, the relevant commands would
be :

.. code-block:: bash

sqlaviz --unique-relations --show-constraints -f out.dot
ccomps -x out.dot | dot | gvpack -array3 | neato -Tpng -n2 -o out.png

.. note::

Some metadata models make SQLAlchemyViz hit a bug in graphviz/dot. In
order to work around this, the rendering commands have been switched
in v0.2 to :

.. code-block:: bash

sqlaviz -p neato --unique-relations -f out.dot
ccomps -x out.dot | dot | gvpack -array3 | neato -Tpng -n2 -o out.png

This change will hopefully be rolled back at some point, once the
underlying bugs have been resolved.

.. note::

Recent update(s) to SQLAlchemyViz / pydot creates a syntax error in the
generated .dot file. This is worked around by changing the sqlaviz command
in v0.3 to :

.. code-block:: bash

sqlaviz -p neato --unique-relations -o node_margin='"0,0"' -f out.dot

Installation & Usage
--------------------

This extension can be installed from pypi :

.. code-block:: bash

pip install sphinxcontrib-sqlalchemyviz

Add the ``sphinxcontrib.sqlalchemyviz`` to Sphinx's list of extensions on the ``conf.py``

In the .rst file where the table should appear, insert the Sphinx
directive provided by this module :

.. code-block:: rest

.. sqlaviz::
:metadataobject: full.importable.path.of.metadata

For a basic usage example, see:

:Python: https://github.com/chintal/tendril/blob/master/tendril/utils/db.py#L201
:Generated: http://tendril.chintal.in/doc/apidoc/tendril.utils.db/#tendril.utils.db.metadata

License
-------

This Sphinx Extension is made available under the BSD 2-clause License. See
the LICENSE file for the full text.