SQLAlchemy 常用基本表

本文介绍了用户表的设计,包括uid、username、password等字段,以及网站公告表的结构,n_id、n_title和n_content。核心内容涉及数据库基础和网站管理模块。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用户表

# 用户表
class Users(Base):
    __tablename__ = 'users'
    uid = Column(Integer, primary_key=True, autoincrement=True)
    username = Column(String(32), nullable=False, unique=True)
    password = Column(String(32), nullable=False, unique=True)
    nickname = Column(String(50))   # 昵称
    email = Column(String(50))      # 邮箱
    sex = Column(Integer)           # 性别
    is_admin = Column(Integer)      # 权限
    openid = Column(String(50))     # 微信openid

    def __init__(self, username, password, nickname, email, sex, is_admin, openid):
        self.username = username
        self.password = password
        self.nickname = nickname
        self.email = email
        self.sex = sex
        self.is_admin = is_admin
        self.openid = openid

网站公告

# 网站公告
class Notice(Base):
    __tablename__ = 'notice'
    n_id = Column(Integer, primary_key=True)
    n_title = Column(String(32), nullable=False)
    n_content = Column(String(32), nullable=False)
    n_time = Column(String(32), nullable=False)

    def __init__(self, n_title, n_content, n_time):
        self.n_title = n_title
        self.n_content = n_content
        self.n_time = n_time
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

有勇气的牛排

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值