1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
ksnowlv@MacBook-Pro-3 Sites % sqlacodegen mysql+pymysql://root:12345678@127.0.0.1:3306/fastapitest --outfile models.py
ksnowlv@MacBook-Pro-3 Sites % ls
models.py
ksnowlv@MacBook-Pro-3 Sites % cat models.py
# coding: utf-8
from sqlalchemy import Column, DateTime, Integer, String, text
from sqlalchemy.dialects.mysql import TINYINT
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
metadata = Base.metadata
class User(Base):
__tablename__ = 'users'
__table_args__ = {'comment': '用户表'}
id = Column(Integer, primary_key=True, index=True, comment='主键')
userid = Column(String(64), nullable=False, index=True, server_default=text("''"), comment='用户userId')
name = Column(String(50), nullable=False, index=True, server_default=text("''"), comment='用户姓名')
age = Column(Integer, nullable=False, server_default=text("'0'"), comment='用户年龄')
phone = Column(String(20), nullable=False, index=True, server_default=text("''"), comment='手机号')
verification_code = Column(String(6), nullable=False, server_default=text("''"), comment='验证码')
token = Column(String(256), nullable=False, unique=True, server_default=text("''"), comment='用户惟一token')
password = Column(String(64), nullable=False, server_default=text("''"), comment='用户密码')
email = Column(String(64), nullable=False, server_default=text("''"), comment='电子邮箱')
status = Column(TINYINT, nullable=False, server_default=text("'1'"), comment='状态,1.正常 -1.黑名单')
created_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
updated_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='更新时间')
delete_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='删除时间')
|