So I read that I can using the cursor in such a way to escape strings:
Code:
cursor.execute("SELECT * FROM `table` WHERE `username` = %s", ("A Name with 'Quotes'"))
And this will yield the same thing as something like:
Code:
cursor.execute("SELECT * FROM `table` WHERE `username` = 'A Name with \'Quotes\''")
Am I correct? Will the prepared parameters always be safe? If not, in what cases will this fail? How do I "sanitize" the parameters so it will be "completely" safe before passing it as the prepared argument?
Also, is something like this supported in MySQLdb's execute:
Code:
cursor.execute("SELECT * FROM `table` WHERE `username` = %(username)s", {'username':"A Name with 'Quotes'"})
Also, I was skimming around sites and read something related to unicode strings needing more "work" or something. What do I need to do so that unicode strings can be used for queries?