Skip to content

Commit

Permalink
'update-dict'
Browse files Browse the repository at this point in the history
  • Loading branch information
cuizhongyi committed May 7, 2020
1 parent 60a18de commit bed79c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def run(self, table_str):
# 打开文件,准备写入
dict_file = open(file_path, 'a', encoding='UTF-8')
dict_file.write('#### %s %s' % (table_name, table_comment))
dict_file.write('\n | 字段名称 | 字段类型 | 默认值 | 字段注释 |')
dict_file.write('\n | --- | --- | --- | --- |')
dict_file.write('\n| 字段名称 | 字段类型 | 默认值 | 字段注释 |')
dict_file.write('\n| --- | --- | --- | --- |')
# 表结构查询
field_str = "COLUMN_NAME,COLUMN_TYPE,COLUMN_DEFAULT,COLUMN_COMMENT from information_schema.COLUMNS"
sql = "select %s where table_schema='%s' and table_name='%s'" % (field_str, self.db_name, table_name)
Expand All @@ -65,8 +65,8 @@ def run(self, table_str):
column_type = field['COLUMN_TYPE']
column_default = str(field['COLUMN_DEFAULT'])
column_comment = field['COLUMN_COMMENT']
info = ' | ' + column_name + ' | ' + column_type + ' | ' + column_default + ' | ' + column_comment + ' | '
dict_file.write('\n ' + info)
info = '| ' + column_name + ' | ' + column_type + ' | ' + column_default + ' | ' + column_comment + ' | '
dict_file.write('\n' + info)
# 关闭连接
print('完成表%s的数据字典' % (table_name,))
dict_file.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def run(self, table_str):
# 打开文件,准备写入
dict_file = open(file_path, 'a', encoding='UTF-8')
dict_file.write('#### %s %s' % (table_name, table_comment))
dict_file.write('\n | 字段名称 | 字段类型 | 默认值 | 字段注释 |')
dict_file.write('\n | --- | --- | --- | --- |')
dict_file.write('\n| 字段名称 | 字段类型 | 默认值 | 字段注释 |')
dict_file.write('\n| --- | --- | --- | --- |')
# 表结构查询
field_str = "COLUMN_NAME,COLUMN_TYPE,COLUMN_DEFAULT,COLUMN_COMMENT from information_schema.COLUMNS"
sql = "select %s where table_schema='%s' and table_name='%s'" % (field_str, self.db_name, table_name)
Expand All @@ -65,8 +65,8 @@ def run(self, table_str):
column_type = field['COLUMN_TYPE']
column_default = str(field['COLUMN_DEFAULT'])
column_comment = field['COLUMN_COMMENT']
info = ' | ' + column_name + ' | ' + column_type + ' | ' + column_default + ' | ' + column_comment + ' | '
dict_file.write('\n ' + info)
info = '| ' + column_name + ' | ' + column_type + ' | ' + column_default + ' | ' + column_comment + ' | '
dict_file.write('\n' + info)
# 关闭连接
print('完成表%s的数据字典' % (table_name,))
dict_file.close()
Expand Down

0 comments on commit bed79c9

Please sign in to comment.