編程時顯示該列表的第3項不存在?
修改方法如下,
我的create table語句如下:CREATE TABLE players (
name VARCHAR(30),
id SERIAL PRIMARY KEY,
wins INTEGER DEFAULT 0,
matches INTEGER DEFAULT 0
);
我正在運行以下PostgreSQL查詢(在Python函數中-將播放器插入數據庫):
^{pr2}$
接下來是這個:query = "SELECT id, name, wins, matches\
FROM players ORDER BY wins DESC;"
嘗試運行腳本時,出現以下錯誤:ProgrammingError: column "id" of relation "players" does not exist
我試過去掉id列,只選擇wins,但它告訴我它也不存在。我還嘗試將玩家表更改為以下內容:CREATE TABLE players (
name VARCHAR(30),
id SERIAL PRIMARY KEY,
wins INTEGER,
matches INTEGER
);
INSERT語句是:query = "INSERT INTO players (name, wins, matches) VALUES (%s,%s,%s);"
c.execute(query,(name,0,0))
并收到以下錯誤:ProgrammingError: column "wins" of relation "players" does not exist
我運行了一個簡單的SELECT*FROM players;在我的終端中,它返回這個表,所以列肯定在那里。。。在name | id | wins | matches