title: How to create SQL queries using an SHA-1 digest of a string using Python
body: <p>I'm trying to insert hundreds of accounts into a <a href="http://en.wikipedia.org/wiki/MySQL" rel="nofollow">MySQL</a> database. I can't insert clear-text passwords and my application is expecting an <a href="http://en.wikipedia.org/wiki/SHA-1" rel="nofollow">SHA-1</a> hash for passwords. A quick online search pointed me to <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="nofollow">Python's</a> hashlib libray.</p>
  
  <p>Here's my Python code to generate a SHA-1 hash:</p>
  
  <pre><code>import hashlib
  m = hashlib.sha1();
  m.update("kpVtk5y6");
  m.digest();
  </code></pre>
  
  <p>How can I use m.digest in the SQL query to store passwords?</p>
  
  <p>My web application uses Java's MessageDigest.digest(mypassword.getBytes()) method to store passwords, so I need to implement something similar in Python in order to auto inject user accounts.</p>