我之前参与过一个 PHP 项目,其中准备好的语句使 SELECT 查询速度提高了 20%.
I worked on a PHP project earlier where prepared statements made the SELECT queries 20% faster.
我想知道它是否适用于 Python?我似乎找不到任何明确说明它可以或不可以的内容.
I'm wondering if it works on Python? I can't seem to find anything that specifically says it does or does NOT.
直接回答,不,不是.
joshperry 的回答很好地解释了它的作用.
joshperry's answer is a good explanation of what it does instead.
来自 eugene y 对类似问题的回答,
查看 MySQLdb 包注释:
Check the MySQLdb Package Comments:
参数化"在 MySQLdb 中通过转义字符串然后盲目地将它们插入到查询中来完成,而不是使用MYSQL_STMT API.结果 unicode 字符串必须经过两个中间表示(编码字符串、转义编码字符串)在它们被数据库接收之前.
"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.
所以答案是:不,不是.
So the answer is: No, it doesn't.
这篇关于Python 是否支持 MySQL 准备语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!