--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/createerm.py Sun Dec 18 11:49:46 2011 +0100
@@ -0,0 +1,48 @@
+from iro import schema
+
+from sqlalchemy.orm import class_mapper
+tables = []
+for attr in schema.__tables__:
+ if attr[0] == '_': continue
+ try:
+ cls = getattr(schema, attr)
+ tables.append(class_mapper(cls))
+ except:
+ 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')