title: SQLAlchemy Query returning None
body: <p>I have a web application using SQLAlchemy and MySQL-server on my ubuntu 16 &amp; Nginx + uwsgi.</p>
  
  <p>while creating the engine, i put </p>
  
  <pre><code>echo=True
  </code></pre>
  
  <p>to get tracing of the query. I have problem registering user, everytime user_loader is called on flask login, I execute:</p>
  
  <pre><code>dbsession.query(User).filter_by(id=user_id).first()
  </code></pre>
  
  <p>The result i get is :</p>
  
  <pre><code>INFO sqlalchemy.engine.base.Engine SELECT user.id AS user_id, user.name AS user_name, user.email AS user_email, user.pass$
  Mar 29 23:48:56 ubuntu-512mb-sgp1-01 uwsgi[26160]: FROM user
  Mar 29 23:48:56 ubuntu-512mb-sgp1-01 uwsgi[26160]: WHERE user.id = %s
  Mar 29 23:48:56 ubuntu-512mb-sgp1-01 uwsgi[26160]:  LIMIT %s
  Mar 29 23:48:56 ubuntu-512mb-sgp1-01 uwsgi[26160]: 2017-03-29 23:48:56,517 INFO sqlalchemy.engine.base.Engine ('61', 1)
  </code></pre>
  
  <p>The result is None. However, the on the above example, using user_id = 61 , , I can find the user on mysql shell in ubuntu to get user id 61.</p>
  
  <p>When i refresh the page a few times, then the result will come out. 
  Once user finished registering, they will be redirected to login page, upon completing the form, it shows error "Please register", which is triggered if user is now found using this query:</p>
  
  <pre><code>dbsession.query(User).filter_by(id=user_id).first()
  </code></pre>
  
  <p>On registration my code is:</p>
  
  <pre><code>user = User(name=name, email=email, password=password)
  dbsession.add(user)
  dbsession.commit()
  return redirect(url_for('login'))
  </code></pre>
  
  <p>checking has been done to ensure name, email password is valid.</p>
  
  <p>Thanks</p>