python - clientlibrary.paramstyle 没有正常工作

标签 python mysql

有一个问题叫做:Python best practice and securest to connect to MySQL and execute queries Kirk Strauser 先生说:

You can see which your client library supports by looking at the paramstyle module-level variable:

>>> clientlibrary.paramstyle
'pyformat'

但是当我在我的 python 3 上运行它时,我得到:

>>> clientlibrary.paramstyle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'clientlibrary' is not defined

我也在pip中搜索过

pip3 search clientlibrary
<nothing>

我能做什么?

最佳答案

paramstyle 是任何 python 数据库模块所必需的(参见 PEP-249 ,clientlibrary 只是您正在使用的 datbase 模块的占位符。

例如

>>> import mysql.connector as clientlibrary
>>> clientlibrary.paramstyle
'pyformat
>>> import mariadb as clientlibrary
>>> clientlibrary.paramstyle
'qmark 

关于python - clientlibrary.paramstyle 没有正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59291900/

相关文章:

python - Python 中的 JIRA OAuth 流程

python - 即使在dockerfile/requirements.txt中添加了numpy之后,在docker容器中使用numpy运行python代码的“Module not found error”

python - 指定 matplotlib 层的顺序

php本地连接mysql数据库

mysql - 在 MySQL 查询问题中获取 SQL 语法错误

mysql - JSP 和 MySQL |创建表时出错

MySQL同时显示数据透视表和直方图

python - 删除两个顶点之间的边[igraph python]

python - Python 正则表达式中插入符号匹配问题

mysql - 为什么 mariadb 分区没有给我更好的性能?