If the name of the data table has "s" at the end, the "s" will be removed from the name of the class in the generated py file. I don't know if it is a bug in the flask-sqlacodegen package or there is a problem with the command line I use.
The command line I used:
flask-sqlacodegen mysql+pymysql://user:password@ip:port/python_codegen?charset=utf8 --tables students --outfile studentsModel.py --flask
The generated code is:
# coding: utf-8
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Student(db.Model):
__tablename__ = 'students'
AutoID = db.Column(db.BigInteger, primary_key=True, info='主键 自动递增')
StudentID = db.Column(db.BigInteger, info='学生ID 业务主键')
StudentName = db.Column(db.String(50), info='学生姓名')
ClassID = db.Column(db.BigInteger, index=True, info='班级ID 外键')
HeadPic = db.Column(db.String(200), info='头像URL')
IsDelete = db.Column(db.Integer, server_default=db.FetchedValue(), info='状态 0-未删除(正常);1- 删除 (停用)')
CreateTime = db.Column(db.DateTime, server_default=db.FetchedValue(), info='创建的时间')
If the name of the data table has "s" at the end, the "s" will be removed from the name of the class in the generated py file. I don't know if it is a bug in the flask-sqlacodegen package or there is a problem with the command line I use.
The command line I used:
flask-sqlacodegen mysql+pymysql://user:password@ip:port/python_codegen?charset=utf8 --tables students --outfile studentsModel.py --flaskThe generated code is: