Python 如何实现烧瓶的功能
我目前正在将一个功能连接到我的flask web应用程序中,需要so指导如何进行连接 我已经做了一个函数,并且(它工作得非常完美)接受了一个参数,它将打印出一个项目列表。用法示例是Python 如何实现烧瓶的功能,python,flask,flask-sqlalchemy,flask-login,Python,Flask,Flask Sqlalchemy,Flask Login,我目前正在将一个功能连接到我的flask web应用程序中,需要so指导如何进行连接 我已经做了一个函数,并且(它工作得非常完美)接受了一个参数,它将打印出一个项目列表。用法示例是 studentatt('15000001') will print the content that 15000000 have in a database. 我的flask应用程序中的一段代码包含 from flask_login import current_user, login_user, logout_u
studentatt('15000001')
will print the content that 15000000 have in a database.
我的flask应用程序中的一段代码包含
from flask_login import current_user, login_user, logout_user, login_required
from app.models import User
from mySQL import studentatt
@app.route('/user/<username>')
@login_required
def user(username):
user = User.query.filter_by(username=username).first_or_404()
return render_template('user.html', user=user)
问题是如何使用导入的函数,以及如何从数据库中提取studentId数据以插入到可以将日期存储到渲染模板以显示在web浏览器中的函数。使用当前用户解决此问题。studentId
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), index=True, unique=True)
studentId = db.Column(db.Integer(), index=True, unique=True)
email = db.Column(db.String(120), index=True, unique=True)