sqlacodegen:通过mysql语句生成sqlalchemy的model

引用网页描述:这个工具读取现有数据库的结构并生成相应的SQLAlchemy模型代码。

使用方法详细描述在如下连接中。

先简要介绍使用方法:

安装:pip install  sqlacodegen 

 

sqlacodegen --outfile db.py --tables table1,table2 mysql+pymysql://root:[email protected]:3306/db_name

在某文件夹下的命令行中输入如上代码,便生成一个 db.py文件,包含了 table1,table2 两个表的orm model ; 

大致文件内容如下:

sqlacodegen:通过mysql语句生成sqlalchemy的model

 

注意点:生成的model中 不包含 comment字段,需要自己添加。

 

 

相关连接:https://pypi.org/project/sqlacodegen/

 

相关文章:

  • 2021-11-05
  • 2021-12-04
  • 2022-02-08
  • 2021-11-07
  • 2022-02-23
  • 2021-11-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
相关资源
相似解决方案