python - python 提供的绑定(bind)数量不正确

标签 python sqlite

我正在 sqllite 中执行以下查询

idP = cur.execute('SELECT id from profs where name = ?',name)

我有一个像这样的数据库表:

| id |   name   |
| 1  |  xxxxxx  |

但我收到错误:提供的绑定(bind)数量不正确。当前语句使用 1,并且提供了 6 个。

我认为字符串“xxxxxx”被视为六个单独的字符。

最佳答案

您可以尝试将参数转换为元组:

idP = cur.execute('SELECT id from profs where name = ?',(name,))

关于python - python 提供的绑定(bind)数量不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33768447/

相关文章:

python - 我不明白这个语法错误的原因

Android - 基于 ORM 的数据库库,可在运行时动态创建表

Python:将SQLITE列的缓冲区类型转换为字符串

android - 当我尝试使用 onItemClickListener 将数据传递给另一个 Activity 时,没有从 sqlite 获取数据

python - 无法在 pandas 中使用数据框元素的平方

获取数字列表中元素层次结构的Pythonic方法

python - Django 错误 : OperationalError: no such table: polls_poll

python - 如何使用 sqlite3 更新几个特定的​​列 - python

python - 有没有办法使用 pandas 根据长度在字符串的字符之间插入空格?

python - seaborn 散点图日期时间 x 轴太宽