from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
db.init_app(app)
params = dict(email=data["email"], rid=data["rid"])
role = models.A(**params)
db.session.add(role)
db.session.commit()
複製程式碼
A 是models檔案中的類
class A(db.Model):
"""
A表的各個欄位
"""
__tablename__ = 'A'
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True, index=True)
rid = db.Column(db.Integer, unique=True, index=True)
pbi_rid = db.Column(db.Integer)
dinfo = db.Column(db.TEXT)
option = db.Column(db.String(255))
time = db.Column(db.DateTime())
複製程式碼