gpt4 book ai didi

Python MySQL 标准

转载 作者:太空宇宙 更新时间:2023-11-03 11:17:15 25 4
gpt4 key购买 nike

在 python 中使用 mysql 的“标准”方式是什么。我将标准定义为不会消失很长时间的东西。

import _mysql
db = _mysql.connect(host, user, pass, db);
db.query("sql");

对比

import MySQLdb
db = MySQLdb.connect(host, user, pass, db);
cursor = db.cursor();
cursor.execute("sql");

显然 MySQLdb 是 _mysql 的包装器,但我讨厌使用包装器,因为它们有可能得不到维护

最佳答案

处理关系数据库引擎的标准方法由 DB-API 定义,如 PEP 249 中所述。 .

关于Python MySQL 标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4227999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com