title: sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type integer: "B1"
body: <p>I am tryng to login the admin on my flask app using ID, when i signup it is taking inputs perfectly, but while getting values from database(postgresql) it showing <strong>&quot;DataError&quot;</strong> I have taken input as alphanumeric in HTML form</p>
  <p>here are my code:</p>
  <p>in model.py i have written code for databese to make columns</p>
  <p>model.py</p>
  <pre><code>class Admin(UserMixin, db.Model):
      id = db.Column(db.String(1000), primary_key=True )
      name = db.Column(db.String(1000))
      email = db.Column(db.String(100), unique=True)
      password = db.Column(db.String(100))
      timestamp = db.Column(db.DateTime)
  </code></pre>
  <p>in this auth.py I writen code for POST methods for signup and login</p>
  <p>auth.py</p>
  <pre><code>@auth.route('/admin')
  def admin():
      return render_template('admin.html')
  
  
  @auth.route('/admin', methods=['POST'])
  def admin_post():
      id = request.form.get('id')
      password = request.form.get('password')
      remember = True if request.form.get('remember') else False
  
  admins = Admin.query.filter_by(id=id).first()
  
  # check if the user actually exists
  # take the user-supplied password, hash it, and compare it to the hashed password in the database
  if not admins or not check_password_hash(admins.password, password):
      flash('Please check your login details and try again.')
      # if the user doesn't exist or password is wrong, reload the page
      return redirect(url_for('auth.admin'))
  
  # if the above check passes, then we know the user has the right credentials
  login_user(admins, remember=remember)
  return redirect(url_for('main.adminOP'))
  
  
   @auth.route('/admin-signup')
   def adminsignup():
       return render_template('admin-signup.html')
  
  
   @auth.route('/admin-signup', methods=['POST'])
   def adminsignup_post():
       id = request.form.get('id')
       email = request.form.get('email')
       name = request.form.get('name')
       password = request.form.get('password')
       timestamp = datetime.now()
  
  # if this returns a admin, then the email already exists in database
  admins = Admin.query.filter_by(email=email).first()
  
  if admins:  # if a user is found, we want to redirect back to signup page so user can try again
      flash('Email address already exists')
      return redirect(url_for('auth.adminsignup'))
  
  # create a new user with the form data. Hash the password so the plaintext version isn't saved.
  new_admin = Admin(id=id, email=email, name=name,
                    password=generate_password_hash(password, method='sha256'), timestamp=timestamp)
  
  # add the new user to the database
  db.session.add(new_admin)
  db.session.commit()
  
  return redirect(url_for('auth.admin'))
  </code></pre>
  <p>The error caught in trace back is:</p>
  <pre><code>sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type 
  integer: &quot;B1&quot;
  LINE 3: WHERE person.id = 'B1'
                            ^
  
  [SQL: SELECT person.id AS person_id, person.email AS person_email, person.password AS person_password, 
  person.name AS person_name, person.timestamp AS person_timestamp
  FROM person
  WHERE person.id = %(pk_1)s]
  [parameters: {'pk_1': 'B1'}]
  (Background on this error at: http://sqlalche.me/e/14/9h9h)
  </code></pre>
  <p>Here B1 is id</p>
  <p>admin-signup.html</p>
  <p>As I said earlier I have used alhapanumeric in input field</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{% extends "base.html" %}
  
  {% block content %}
  &lt;div class="column is-4 is-offset-4"&gt;
      &lt;h3 class="title has-text-info"&gt;Sign Up&lt;/h3&gt;
      &lt;div class="box"&gt;
          {% with messages = get_flashed_messages() %}
          {% if messages %}
          &lt;div class="notification is-danger"&gt;
              {{ messages[0] }}. Go to &lt;a href="{{ url_for('auth.admin') }}"&gt;login page&lt;/a&gt;.
          &lt;/div&gt;
          {% endif %}
          {% endwith %}
          &lt;form method="POST" action="/admin-signup"&gt;
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="text" name="id" placeholder="Your ID" autofocus="" pattern="[a-zA-Z0-9]+"&gt;&lt;span
                          class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                      &lt;small&gt; Remember: ID is you employee number &lt;/small&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="email" aria-required="true" name="email" placeholder="Email"
                          autofocus=""&gt;&lt;span class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="text" aria-required="true" name="name" placeholder="Name"
                          autofocus=""&gt;&lt;span class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="password" aria-required="true" name="password"
                          placeholder="Password"&gt;&lt;span class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;button class="button is-block is-info is-large is-fullwidth"&gt;Sign Up&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}</code></pre>
  </div>
  </div>
  </p>
  <p>admin.html</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{% extends "base.html" %}
  
  {% block content %}
  &lt;div class="column is-4 is-offset-4"&gt;
      &lt;h3 class="title has-text-info"&gt;Admin Login&lt;/h3&gt;
      &lt;div class="box"&gt;
          {% with messages = get_flashed_messages() %}
          {% if messages %}
          &lt;div class="notification is-danger"&gt;
              {{ messages[0] }}
          &lt;/div&gt;
          {% endif %}
          {% endwith %}
          &lt;form method="POST" action="/admin"&gt;
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="text" name="id" placeholder="Your ID" autofocus="" required pattern="[a-zA-Z0-9]+"&gt;&lt;span
                          class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                      &lt;small&gt; HINT: ID is you employee number &lt;/small&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="field"&gt;
                  &lt;div class="control has-icons-left has-icons-right"&gt;
                      &lt;input class="input is-large" type="password" name="password" placeholder="Your Password"&gt;&lt;span
                          class="icon is-small is-left"&gt;
                          
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="field"&gt;
                  &lt;label class="checkbox"&gt;
                      &lt;input type="checkbox"&gt;
                      Remember me
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;button class="button is-block is-info is-large is-fullwidth"&gt;Login&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}</code></pre>
  </div>
  </div>
  </p>
  <p>After editing code i got this same error caught in debugging
  <a href="https://i.stack.imgur.com/d9aBC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d9aBC.png" alt="enter image description here" /></a></p>
  <p>this is person model</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class person(UserMixin, db.Model):
      # primary keys are required by SQLAlchemy
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String(100), unique=True)
      password = db.Column(db.String(100))
      name = db.Column(db.String(1000))
      timestamp = db.Column(db.DateTime)</code></pre>
  </div>
  </div>
  </p>