我正在尝试使用python从SQLite数据库中选择数据并面临此错误:
near“,”:语法错误
表格结构:
CREATE TABLE schedule (
game_week TEXT NOT NULL,
hteam TEXT,
ateam TEXT,
gdate TEXT,
gtime TEXT,
gtvstn TEXT
);
每个select语句都有唯一的行。
我的代码:
if (choice == "Y" or choice == 'y'):
print("please enter game week, home and away team")
gme_week = input("enter game week")
hm_team = input("enter home team")
aw_team = input("enter away team")
cur.execute('''SELECT * FROM schedule WHERE (game_week, hteam, ateam,) VALUES (?, ?, ?)''',
( gme_week, hm_team, aw_team)) // this is where the code is failing
try:
row = cur.fetchone()
print (row)
except:
print ("row not found! check values once and try again!")
我是python的新手,并且在python中并不真正了解sqlite语法。 我使用的是python 3.5和sqlite3
任何人都可以帮帮我吗?
非常感谢提前
答案 0 :(得分:2)
正确的SQL语句是:
SELECT * FROM schedule WHERE game_week = ? and hteam = ? and ateam = ?