2021年3月17日星期三

How do i get specific values using flask-sqlalchemy?

I'm trying to build signup and signin using flask + sql + sqlalchemy. I tried many methods to extract specific data from columns. but when i give query, it just return named tuple. like [, ] I just want to get userid from columns. Any help? This is my code

app.py

@app.route('/login', methods=['GET','POST'])    def login():      form = LoginForm()      user_id = form.data.get('userid')      keyword = "%{}%".format(form.data.get('userid'))      addr = User.query.filter(User.userid.like(keyword)).all()      print(addr)          return render_template('login.html', form=form)  

and this is my sql table column

enter image description here

and this is what i returned

 * Restarting with stat   * Debugger is active!   * Debugger PIN: 161-830-439   * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)  [<User 2>]  127.0.0.1 - - [18/Mar/2021 13:00:32] "POST /login HTTP/1.1" 200   

I just want to get userid using list. like this

['min', 'test1234']  

any help?

https://stackoverflow.com/questions/66684641/how-do-i-get-specific-values-using-flask-sqlalchemy March 18, 2021 at 12:09PM

没有评论:

发表评论