suche auch im Homeverzeichnis nach config Datei.
# Copyright (c) 2012 netzguerilla.net <iro@netzguerilla.net>
#
# This file is part of Iro.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# #Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from iro.model import schema
tables = schema.Base.metadata.sorted_tables
tables_cls={}
for i in dir(schema):
if i.startswith("__") or i == "Base":
continue
try:
a = getattr(schema,i)
tables_cls[a.__tablename__] = a
except AttributeError:
pass
#schema plot
def createSchemaPlot(fname):
from sqlalchemy_schemadisplay3 import create_schema_graph
graph = create_schema_graph(metadata=schema.Base.metadata,
show_datatypes=True, # The image too large if datatypes shown
show_indexes=True, # ditto for indexes
rankdir='LR', # From left to right (instead of top to bottom)
concentrate=True, # Don't try to join the relation lines together
)
graph.set_size('6.5,10')
#graph.set_ratio("fill")
graph.write_svg(fname)
#umlplot
def createUMLPlot(fname):
from sqlalchemy_schemadisplay3 import create_uml_graph
from sqlalchemy.orm import class_mapper
mappers = []
for attr in dir(schema.model):
if attr[0] == '_': continue
try:
cls = getattr(schema.model, attr)
mappers.append(class_mapper(cls))
except:
pass
#pass them to the function and set some formatting options
graph = create_uml_graph(mappers,
show_operations=False, # not necessary in this case
show_multiplicity_one=True, # some people like to see the ones
show_attributes=True,
)
graph.set_size('6,5')
graph.set_ratio("fill")
graph.write_png('test.png')