title: Confusion between prepared statement and parameterized query in Python
body: <p>As far as I understand, prepared statements are (mainly) a database feature that allows you to separate parameters from the code that uses such parameters. Example:</p>
  
  <pre><code>PREPARE fooplan (int, text, bool, numeric) AS
      INSERT INTO foo VALUES($1, $2, $3, $4);
  EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);
  </code></pre>
  
  <p>A parameterized query substitutes the manual string interpolation, so instead of doing</p>
  
  <pre><code>cursor.execute("SELECT FROM tablename WHERE fieldname = %s" % value)
  </code></pre>
  
  <p>we can do</p>
  
  <pre><code>cursor.execute("SELECT FROM tablename WHERE fieldname = %s", [value])
  </code></pre>
  
  <p>Now, it seems that prepared statements are, for the most part, used in the database language and parameterized queries are mainly used in the programming language connecting to the database, although I have seen exceptions to this rule.</p>
  
  <p>The problem is that asking about the difference between prepared statement and parameterized query brings a lot of confusion. Their purpose is admittedly the same, but their methodology seems distinct. Yet, there are <a href="http://www.programmerinterview.com/index.php/database-sql/parameterized-queries-vs-prepared-statements/" rel="noreferrer">sources</a> indicating that both are the same. MySQLdb and Psycopg2 seem to support parameterized queries but don’t support prepared statements (e.g. <a href="https://stackoverflow.com/a/17237567/460147">here</a> for MySQLdb and in the <a href="https://wiki.postgresql.org/wiki/Python_PostgreSQL_Driver_TODO" rel="noreferrer">TODO list for postgres drivers</a> or <a href="https://groups.google.com/d/msg/sqlalchemy/LN0evK1hyOM/78nvIwtT7GgJ" rel="noreferrer">this answer</a> in the sqlalchemy group). Actually, there is a <a href="https://gist.github.com/dvarrazzo/3797445" rel="noreferrer">gist</a> implementing a psycopg2 cursor supporting prepared statements and a minimal <a href="https://stackoverflow.com/questions/9866350/prepared-statements-using-psycopg">explanation</a> about it. There is also a <a href="http://initd.org/psycopg/articles/2012/10/01/prepared-statements-psycopg/" rel="noreferrer">suggestion</a> of subclassing the cursor object in psycopg2 to provide the prepared statement manually.</p>
  
  <p>I would like to get an authoritative answer to the following questions:</p>
  
  <ul>
  <li><p>Is there a meaningful difference between prepared statement and parameterized query? Does this matter in practice? If you use parameterized queries, do you need to worry about prepared statements?</p></li>
  <li><p>If there is a difference, what is the current status of prepared statements in the Python ecosystem? Which database adapters support prepared statements?</p></li>
  </ul>