Does Python support MySQL prepared statements?(Python 是否支持 MySQL 准备语句?)
问题描述
我之前参与过一个 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 准备语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Python 是否支持 MySQL 准备语句?


基础教程推荐
- 带更新的 sqlite CTE 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01