Does the MySQLdb module support prepared statements?

Does MySQLdb support server-side prepared statements ? I can not understand this from my manual.

+11
python mysql prepared-statement
Mar 11 '10 at 11:37
source share
2 answers

Check MySQLdb Package Comments :

"Parameterization" is performed in MySQLdb by escaping strings and then blindly interpolating them into the query, instead of using the MYSQL_STMT API. As a result, unicode strings must go through two intermediate representations (encoded string, escaped string) before they are received by the database.

So the answer is: No, it is not.

+16
Mar 11 '10 at 14:05
source share

He has some kind of parameterization, yes .

Even then, I advise you to upgrade to oursql . It brings many advantages over MySQLdb:

  • oursql has real parameterization.
  • oursql allows you to transfer text or binary data to the database and be output from the database, instead of requiring that everything be buffered in the client.
  • oursql can insert rows lazily and retrieve rows lazily.
  • By default, ussql supports unicode support.
  • oursql supports python 2.4 through 2.7 without any warnings about the failure of version 2.6+ (see PEP 218) and without a complete failure of 2.7 (see PEP 328).
  • oursql is licensed under the BSD license.
+13
Mar 11
source share



All Articles