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 准备语句?


- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01