from sqlalchemy import Column
from sqlalchemy import Integer, Float
from sqlalchemy import String, Boolean
from app.models.base import db
class User(db.Model):
id = Column(Integer, primary_key=True)
nickname = Column(String(24), nullable=False)
phone_number = Column(String(18), unique=True)
email = Column(String(50), unique=True, nullable=False)
confirmed = Column(Boolean, default=False)
beans = Column(Float, default=0)
send_counter = Column(Integer, default=0)
receive_counter = Column(Integer, default=0)
wx_open_id = Column(String(50))
wx_name = Column(String(32))
from app.models.base import db
from sqlalchemy import Column, String, Integer, ForeignKey, Boolean
from sqlalchemy.orm import relationships
class Gift(db.Model):
id = Column(Integer, primary_key=True, autoincrement=True)
# relationships表示管理关系
user = relationships('User')
# ForeignKey定义外键约束
uid = Column(Integer, ForeignKey('user.id'))
# 书籍我们记录isbn编号,因为书籍信息是从网络获取的
isbn = Column(String(15),nullable=True)
# 是否已经赠送出去
launched = Column(Boolean, default=False)
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import SmallInteger, Column
__author__ = "gaowenfeng"
db = SQLAlchemy()
class Base(db.Model):
__abstract__ = True
create_time = Column(Integer)
status = Column(SmallInteger, default=1)
def __init__(self):
self.create_time = int(datetime.now().timestamp())