title: Python SQL Injection safe
body: <p>Short question: I want to make my code safer but in this line it crashes:</p>
  
  <pre><code>self.cursor.execute("SELECT device_name FROM device WHERE device_id = %s", self.device_id)
  </code></pre>
  
  <p>This is working fine, but not safe for injection attacks:</p>
  
  <pre><code>self.cursor.execute("SELECT device_name FROM device WHERE device_id = " + str(self.device_id))
  </code></pre>
  
  <p>I have no idea, whats wrong in the first line.</p>
  
  <pre><code>[...] raise errors.get_exception(packet)
  mysql.connector.errors.ProgrammingError: 1064 (42000): Unknown error
  </code></pre>