from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import enum
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root1234@localhost/kaka_db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=True
db = SQLAlchemy(app)
class UserType(enum.Enum):
puTongUser = 0
guanLiYuan = 1
superGuanLiYuan = 2
changJia = 3
class User(db.Model):
__talbename__ = 'user_table'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
userName = db.Column(db.String(80), unique=True, nullable=False)
passWord = db.Column(db.String(80), nullable=False)
phone = db.Column(db.String(80))
email = db.Column(db.String(80), unique=True)
userType = db.Column(db.Enum(UserType))
code = db.Column(db.String(80), unique=True)
pushToken = db.Column(db.String(80))
token = db.Column(db.String(80))
regiserType = db.Column(db.Integer, unique=True)
userMoney = db.Column(db.Float)
def __init__(self, username, password, phone = None, email = None, code = None, pushToken = None, userType = 0, registerType = 0, userMoney = 0.0):
self.userName = username
self.passWord = password
self.phone = phone
self.email = email
self.code = code
self.pushToken = pushToken
self.userType = userType
self.regiserType = registerType
self.userMoney = userMoney
db.create_all()
db.session.commit()
if __name__ == '__main__':
app.run(debug = True)