Screen Link: https://app.dataquest.io/m/193/guided-project%3A-designing-and-creating-a-database/6/adding-the-team-and-game-tables
Your Code:
c1 = """
CREATE TABLE IF NOT EXISTS game(
game_id TEXT PRIMARY KEY,
date TEXT,
number_of_game INTEGER,
park_id TEXT,
length_outs INTEGER,
day BOOLEAN,
completion TEXT,
forefeit TEXT,
protest TEXT,
attendance INTEGER,
legnth_minutes INTEGER,
additional_info TEXT,
acquisition_info TEXT,
FOREIGN KEY (park_id) REFERENCES park(park_id)
);
"""
c2 = """
INSERT OR IGNORE INTO game
SELECT
game_id,
date,
number_of_game,
park_id,
length_outs,
CASE
WHEN day_night = "D" THEN 1
WHEN day_night = "N" THEN 0
ELSE NULL
END
AS day,
completion,
forefeit,
protest,
attendance,
length_minutes,
additional_info,
acquisition_info
FROM game_log;
"""
q = """
SELECT * FROM game
LIMIT 5;
"""
run_command(c1)
run_command(c2)
run_query(q)
What I expected to happen: I expected a Table called “game” to be created and values inserted in it.
What actually happened: I get an error
OperationalErrorTraceback (most recent call last)
<ipython-input-23-755c54a9cb88> in <module>()
48
49 run_command(c1)
---> 50 run_command(c2)
51 run_query(q)
<ipython-input-11-5892acdf2541> in run_command(c)
9 conn.execute('PRAGMA foreign_keys = ON;')
10 conn.isolation_level = None
---> 11 conn.execute(c)
12
13 def show_tables():
OperationalError: no such table: main.par
Other details: I have throroughly perused my code and my tables are available.