title: how can I pass a number larger than 9 to a psycopg2 select statement
body: <p>I have a simple Flask app. The app connects with a database of movie reviews. I built a function to retrieve data which takes a max_count argument. but for some reason, I can only pass a number smaller than 10.  The app works fine if I pass 3 or 9. Here is my code:</p>
  
  <pre><code>from flask import Flask, request
  import requests
  import psycopg2
  from psycopg2.extras import RealDictCursor
  import json
  app = Flask(__name__)
  
  
  
  @app.route('/')
  def home():
      return "Hello!"
  
  @app.route('/get_total_data_count/&lt;label&gt;', methods=['GET'])
  def get_total_data_count(label):
      connection = psycopg2.connect(user="barmej", password="password", host="127.0.0.1", port="5432", database="labeling")
      cursor = connection.cursor()
      try:
          if label == 'positive':
              cursor.execute("SELECT * FROM data_labeling WHERE label_number = 0 limit 100;")
          elif label == 'negative':
              cursor.execute("SELECT * FROM data_labeling WHERE label_number = 1 limit 100;")
          elif label == 'all':
              cursor.execute("SELECT * FROM data_labeling;")
          return "The count is " + str(cursor.rowcount)
      except:
          return "Error! type: positive, negative or all"
      cursor.close()
      connection.close()
  
  @app.route('/get_data', methods=['GET'])
  def get_data_test():
      try:
          connection = psycopg2.connect(user="barmej", password="password", host="127.0.0.1", port="5432", database="labeling")
          cursor = connection.cursor()
          max_count = request.args.get('max_count')
          sort_order = request.args.get('sort_order')
          if sort_order == 'ASC':
              insert = "SELECT text FROM data_input ORDER BY ASC limit %s"
              parameters = max_count
              cursor.execute(insert, parameters)
              result = cursor.fetchall()
  
          elif sort_order == 'DESC':
              insert = "SELECT text FROM data_input ORDER BY DESC limit %s "
              parameters = max_count
              cursor.execute(insert, (parameters))
              result = cursor.fetchall()
  
          dic = {}
          dic['text'] = result
          return dic
      except:
          return "Error!, make sure url include: a max count and either 'ASC' or 'DESC' Argument"
      cursor.close()
      connection.close()
  
  if __name__ == "__main__":
      app.run(debug=True, port=3000)
  
  </code></pre>
  
  <p>The call is done in python shell from the server: </p>
  
  <pre><code>&gt;&gt;&gt; import requests
  &gt;&gt;&gt; param = {'max_count': 12, 'sort_order': 'ASC'}
  &gt;&gt;&gt; r = requests.get('http://127.0.0.1:3000/get_data', params=param)
  &gt;&gt;&gt; r.text
  
  </code></pre>
  
  <p>I tried the code without the exception and the error is:</p>
  
  <pre><code>psycopg2.errors.SyntaxError: syntax error at or near "%"\nLINE 1: SELECT text FROM data_input limit %s
  </code></pre>