我有一个Python 2.7项目的问题.
我正在尝试将变量设置为从sqlite3数据库检索的值,但我遇到了麻烦.这是我到目前为止的代码,以及我收到的错误.是的,连接打开就好了,表,列和指示的行就在那里.
import sqlite3 import Trailcrest
conn = sqlite3.connect('roster.paw')
c = conn.cursor()
def Lantern(AI):
"""Pulls all of the data for the selected user."""
Trailcrest.FireAutoHelp = c.execute("""select fireautohelp
from roster
where index = ?;""", (AI,) ).fetchall()
Run Code Online (Sandbox Code Playgroud)
错误是:
> Traceback (most recent call last):
> File "<pyshell#4>", line 1, in <module> Lantern(1)
> File "C:\Users\user\MousePaw Games\Word4Word\PYM\Glyph.py", line 20,
> in Lantern
> Trailcrest.FireAutoHelp = c.execute("""select fireautohelp from roster where index = ?;""", (AI,)).fetchall()
> OperationalError: near "index": syntax error
Run Code Online (Sandbox Code Playgroud)
正如Thomas K在评论中提到的那样,index是一个SQL关键字.
您可以重命名该列,也可以用反引号括起来:
Trailcrest.FireAutoHelp = c.execute("""select fireautohelp
from roster
where `index` = ?;""", (AI,) ).fetchall()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
942 次 |
| 最近记录: |