Вот код в main.py:
@app.route('/forum/<int:forum_id>')
def forum(forum_id):
conn = sqlite3.connect('db.db')
cursor = conn.cursor()
cursor.execute('SELECT * FROM forums WHERE id=?', (forum_id,))
forum_data = cursor.fetchone()
cursor.execute('SELECT * FROM threads WHERE forum_id=?', (forum_id,))
threads = cursor.fetchall()
conn.close()
if forum_data is None:
return 'Форум не найден'
else:
return render_template('forum.html', forum=forum_data, threads=threads)
В БД id у forums есть:
CREATE TABLE IF NOT EXISTS forums (
id INTEGER PRIMARY KEY,
category_id INTEGER NOT NULL,
name TEXT NOT NULL,
FOREIGN KEY (category_id) REFERENCES categories (id)
)
Но когда захожу например на
/forum/1
То мне пишет:
sqlite3.OperationalError
sqlite3.OperationalError: no such column: id