title: how to safely generate a SQL LIKE statement using python db-api
body: <p>I am trying to assemble the following SQL statement using python's db-api:</p>
  
  <pre><code>SELECT x FROM myTable WHERE x LIKE 'BEGINNING_OF_STRING%';
  </code></pre>
  
  <p>where BEGINNING_OF_STRING should be a python var to be safely filled in through the DB-API. I tried</p>
  
  <pre><code>beginningOfString = 'abc'
  
  cursor.execute('SELECT x FROM myTable WHERE x LIKE '%s%', beginningOfString) 
  cursor.execute('SELECT x FROM myTable WHERE x LIKE '%s%%', beginningOfString)
  </code></pre>
  
  <p>I am out of ideas; what is the correct way to do this?</p>