title: What is the correct way to form MySQL queries in python?
body: <p>I am new to python, I come here from the land of PHP. I constructed a SQL query like this in python based on my PHP knowledge and I get warnings and errors</p>
  
  <pre><code>cursor_.execute("update posts set comment_count = comment_count + "+str(cursor_.rowcount)+" where ID = " + str(postid))
  # rowcount here is int
  </code></pre>
  
  <p>What is the right way to form queries?</p>
  
  <p>Also, how do I escape strings to form SQL safe ones? like if I want to escape -, ', " etc, I used to use addslashes. How do we do it in python?</p>
  
  <p>Thanks</p>