title: Python character formatting with mySQL raw db query giving me problems
body: <p>I'm having a problem with trying to install a search function on my web application. The problem is with the following code. I've tried the following two queries but python gives me an error that I will list below:</p>
  
  <pre><code>def searchBox(user_id, searchparams):
  
  try:
      cursor = connection.cursor()
  
      if cursor:
          sql = "SELECT * FROM db_email WHERE user_id = %d AND deleted = 0 AND subject LIKE '%%%s%%';"
          cursor.execute(sql % (user_id, searchparams)
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>try:
      cursor = connection.cursor()
  
      if cursor:
          sql = "SELECT * FROM db_email WHERE user_id = %d AND deleted = 0 AND subject LIKE " + "'%" + searchparams + "%';"
          cursor.execute(sql % (user_id))
  </code></pre>
  
  <p>Both return this error for me:</p>
  
  <pre><code>TypeError: not enough arguments for format string
  </code></pre>
  
  <p>This is the only raw queries that I have had any trouble with and it's related to the way I need to call LIKE. I could write a stored procedure instead to bypass python but I feel like I'm doing something dumb and overlooking an issue. Any help would be appreciated</p>
  
  <hr>
  
  <p>Thank you. I think a part of the problem is with my LIKE query I need my searchparams to be enclosed with percentage signs and the below answer doesn't work like so - </p>
  
  <pre><code>subject LIKE '%somestringimlookingfor%' 
  </code></pre>
  
  <p>with the code above it seems to come out to 'test'%''. Any ideas?</p>