user_exists = db.GqlQuery("select * from User where user_id in '%s'" % username)
if len(user_exists) > 0:
Your code would work if you were calling
.fetch(1) on the GqlQuery object.
user = db.GqlQuery("select * from User where user_id = :1", username).get() if user: # now `user` will contain a value if the query returns a value or None if not
You should prefer use of query parameters to string-interpolation as using the API makes your code less vulnerable to SQL-injection attack.