title: Error while updating the postgres database through python
body: <ul>
  <li>I am trying to update a record from python. The database used is postgres.</li>
  <li>Name of the database is &quot;users&quot;</li>
  <li>The server is hosted on pgadmin4.</li>
  <li>I am taking the values from the html file and the updating the status field.</li>
  <li><code>application.py</code></li>
  </ul>
  <pre><code>@app.route(&quot;/enable&quot;, methods=['POST'])
  def enable():
      if request.method == &quot;POST&quot;:
          try:
              connection = psycopg2.connect(user=&quot;postgres&quot;,
                                            password=&quot;postgres&quot;,
                                            host=&quot;localhost&quot;,
                                            port=&quot;5432&quot;,
                                            database=&quot;admins&quot;)
  
              cursor = connection.cursor()
  
              user_name = request.form['user_name']
              status = 'Enable'
              print(user_name)
              print(status)
              sql_update_query = &quot;&quot;&quot;UPDATE users SET status = %s WHERE username = '%s'&quot;&quot;&quot;
              record_to_update = (sql_update_query, (user_name, status))
              cursor.execute(sql_update_query, record_to_update)
              connection.commit()
              print(&quot;Record updated sucessfully&quot;)
  
          except (Exception, psycopg2.Error) as error:
              print(&quot;Error in update operation&quot;, error)
  
          finally:
          # closing database connection.
              if (connection):
                  cursor.close()
                  connection.close()
                  print(&quot;PostgreSQL connection is closed&quot;)
      return redirect(url_for('list'))
  </code></pre>
  <ul>
  <li><p>The screenshot of the terminal
  <a href="https://i.stack.imgur.com/LQ2TY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LQ2TY.png" alt="enter image description here" /></a></p>
  </li>
  <li><p>In the screenshot <code>admin1</code> is the username and <code>Enable</code> is the value I am passing as the value for the status column to be updated. By default it is <code>Active</code>.</p>
  </li>
  </ul>