MySQLdb模块是否支持准备好的语句?

2024-06-07 07:06:01 发布

您现在位置:Python中文网/ 问答频道 /正文

MySQLdb是否支持服务器端prepared statements?我无法从它的说明书上看出这一点。


Tags: 服务器端mysqldbstatements说明书prepared
2条回答

检查MySQLdbPackage Comments

"Parameterization" is done 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 have to go through two intermediate representations (encoded string, escaped encoded string) before they're received by the database.

所以答案是:不,不是

它有某种参数化,yes

即便如此,我还是建议你换成oursql。它将a lot of advantages带到MySQLdb:

  • 我们的sql有真正的参数化。
  • oursql允许文本或二进制数据流入数据库并流出数据库,而不需要在客户端缓冲所有数据。
  • 我们的sql既可以惰性地插入行,也可以惰性地获取行。
  • 默认情况下,oursql支持unicode。
  • oursql支持python 2.4到2.7,在2.6+上没有任何不推荐警告(参见PEP 218),在2.7上没有完全失败(参见PEP 328)。
  • 我们的SQL是根据BSD许可证授权的。

相关问题 更多 >