首页 > 编程知识 正文

数据库文档生成工具,mysql数据库简介

时间:2023-05-05 11:32:49 阅读:176822 作者:4807

直接访问fzdxwz

#! /usr/bin/python

#-* -编码: utf-8-* -

import mysql.connector

来自文档导入文档

db='targetDB '

host='localhost '

user='username '

password='password '

端口=3306

conn=MySQL.connector.connect (host=host,user=user,passwd=password,db=db,port=port ) ) ) ) )

sql='select table_name,table _ commentfrominformation _ schema.tableswheretable _ schema=' { } '.format (

文档=文档(

for(table_name,table_comment ) in cursor.fetchall ) ) :

document.add _ heading (table _ name,level=1) )。

document.add _ paragraph (table _ comment )

table=document.add _ table (rows=1,cols=3,style='Table Grid ' ) ) ) ) ) ) ) ) ) ) ) )

hdr_cells=table.rows[0].cells

hdr_cells[0].text=u '字段'

hdr_cells[1].text=u '类型'

hdr_cells[2].text=u '说明'

for(field,type,_,_,_,_,_,_,_,_,_,comment ) in cursor.fetchall ) :

row_cells=table.add_row ().cells

row_cells[0].text=field

row_cells[1].text=type

row_cells[2].text=comment

document.save(db.docx ) )。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。