Python 是否支持 MySQL 准备语句?

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)