Last Updated: February 25, 2016
·
2.567K
· Lorin Hochstein

ER diagram for OpenStack database

If you want to generate an entity-relationship diagram for the tables in an OpenStack Compute (nova) database, this script will introspect the sqlalchemy models and generate a png.

#!/usr/bin/env python
import ConfigParser
from sqlalchemy import MetaData
from sqlalchemy_schemadisplay import create_schema_graph
config = ConfigParser.RawConfigParser()
config.read('/etc/nova/nova.conf')
connection = config.get("DEFAULT", "sql_connection")
graph = create_schema_graph(metadata=MetaData(connection),
                 show_datatypes=False,show the datatypes
                 show_indexes=False,
                 rankdir='LR',
                 concentrate=False)
graph.write_png('dbschema.png')