我正在尝试从表中选择所有具有 user_id = 0 和 type 我可以作为参数给出。
user_id = 0
type
我的代码是:
get_all_parking_by_type = 'SELECT * FROM Parking WHERE type = ? and user_id = 0 VALUES (?)' cursor.execute(get_all_parking_by_type, ('guest')) guests = cursor.fetchall()
错误是:
sqlite3.OperationalError:靠近“VALUES”:语法错误
这可能很愚蠢,但我不知道如何解决。
这里有两个错误:
VALUES
('guest')
('guest', )
尝试
get_all_parking_by_type = 'SELECT * FROM Parking WHERE type = ? and user_id = 0' # Notice the comma after `'guest'` cursor.execute(get_all_parking_by_type, ('guest', )) guests = cursor.fetchall()