title: Sanitizing user-provided SQL with Python?
body: <p>I'm working on a small app which will help browse the data generated by <a href="http://wolever.net/~wolever/wiki/vim-logging" rel="nofollow noreferrer">vim-logging</a>, and I'd like to allow people to run arbitrary SQL queries against the datasets.</p>
  
  <p>How can I do that safely?</p>
  
  <p>For example, I'd like to let someone enter, say, <code>SELECT file_type, count(*) FROM commands GROUP BY file_type</code>, then send the result back to their web browser.</p>