Skip to content

Commit 42d5d01

Browse files
committed
draw方法更新
1 parent 7ba9257 commit 42d5d01

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/generator.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ def _table_end(self):
158158
</TABLE>
159159
"""
160160

161+
def relation(self, table_a, table_b, label):
162+
"""
163+
样式暂时不处理
164+
:param table_a:
165+
:param table_b:
166+
:param label:
167+
:return:
168+
"""
169+
170+
return """
171+
%s -> %s
172+
[label="%s"] [arrowhead=none, arrowtail=dot, dir=both];
173+
""" % (table_a, table_b, label)
174+
161175
def label(self, *args, **kwargs):
162176
"""
163177
:return:
@@ -182,7 +196,10 @@ def table(self, *args, **kwargs):
182196
if not data or not table_name:
183197
raise AttributeError('param is empty')
184198

185-
title = "%s(%s)" % (table_name, table_comment)
199+
title = table_name
200+
if table_comment:
201+
title = "%s(%s)" % (table_name, table_comment)
202+
186203
# 字段长度要保持一致
187204
output = [self._table_start(), self.title(title)]
188205

pydbdoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def output_graph(self, dest, override):
181181
'table_name': table_name,
182182
'table_comment': table_comment,
183183
# 'columns': ['字段名', '类型', '是否可NULL', '描述'],
184-
'data': [[column.name, column.field_type, column.if_null, column.comment.replace(os.linesep, '')] for
184+
'data': [[column.name, column.field_type, column.if_null, column.comment] for
185185
column in columns],
186186
}
187187
_output.append(generator.label(**_table_data))

0 commit comments

Comments
 (0)