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 准备语句?
基础教程推荐
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- oracle区分大小写的原因? 2021-01-01
