美文网首页
使用Flask工具包flask-sqlacodegen生成ORM

使用Flask工具包flask-sqlacodegen生成ORM

作者: kwok1993 | 来源:发表于2020-07-23 17:20 被阅读0次

一、pip安装flask工具包flask-sqlacodegen

pip使用pypi国内源,下载速度会比较快,这边使用的是清华源。

pip install flask-sqlacodegen -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

二、使用工具生成ORM model表

2.1整个数据库生成ORM model表

flask-sqlacodegen "数据库类型://用户名:密码@数据库IP/数据库名" --outfile "保存目录/表结构文件名" --flask

示例:

flask-sqlacodegen "mysql://root:pwd@127.0.0.1/xxoo" --outfile "models/model.py"  --flask

2.2 单张数据表生成ORM model表

flask-sqlacodegen "数据库类型://用户名:密码@数据库IP/数据库名" --tables 数据表名 --outfile "保存目录/表结构文件名" --flask

示例:

flask-sqlacodegen "mysql://root:pwd@127.0.0.1/xxoo" --tables user --outfile "models/User.py"  --flask

相关文章

网友评论

      本文标题:使用Flask工具包flask-sqlacodegen生成ORM

      本文链接:https://www.haomeiwen.com/subject/ygdhlktx.html