title: How to fetch column values using SQLAlchemy?
body: <p>I am using Flask+Python and to check if a <strong>username</strong> (and <strong>email</strong>) is already taken or not i am using this logic:</p>
  
  <pre><code>@app.route('/register', methods=['GET', 'POST'])
  def register():
      form = SignupForm()
      if form.validate_on_submit():
        user = Users.query.filter_by(username=form.username.data).first()
        email = Users.query.filter_by(email=form.email.data).first()
        if form.username.data in user:
          error = 'Username already taken. Choose another'
        elif form.email.data in email:
          error = 'Email already registered. Login or register with another Email'
        else:
            user = Users( 
            form.username.data,
            form.password.data,
            #form.confirm.data ,
            form.email.data,
            1,
            # form.cityaddress.data,
            # form.countryaddress.data,
            #form.accept_tos.data,
        )
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('index'))
  </code></pre>
  
  <p>But its giving error like <code>object has no attribute 'username'</code></p>
  
  <p>I know my logic for fetching data from db is not correct. I have little knowledge of SQLalchemy.</p>
  
  <p>Could you suggest me How can i fetch <code>Username</code> (and <code>Email</code>) column value from table <code>Users</code> and then check them if there are same as <code>form.username.data</code> ?</p>