diff --git a/__pycache__/app.cpython-310.pyc b/__pycache__/app.cpython-310.pyc index 6833017..03495df 100644 Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ diff --git a/app.py b/app.py index 7f2438c..cd18645 100644 --- a/app.py +++ b/app.py @@ -109,11 +109,14 @@ def create(): (new_topic,)) conn.commit() topic_tag = new_topic - + + cat_id = conn.execute('SELECT id FROM categories WHERE category_name = (?);', + (category_name,)).fetchone()['id'] + topic_id = conn.execute('SELECT id FROM topics WHERE content = (?);', - (topic_tag,)).fetchone()['id'] + (topic_tag,)).fetchone()['id'] conn.execute('INSERT INTO topic_cards (topic_id, card_id) VALUES (?,?)', - (topic_id, cat_id)) + (topic_id, cat_id)) if not content: flash('plz write a content!') @@ -121,10 +124,15 @@ def create(): cat_id = conn.execute('SELECT id FROM categories WHERE category_name = (?);', (category_name,)).fetchone()['id'] - + conn.execute('INSERT INTO cards (content, category_id) VALUES (?,?)', (content, cat_id)) - + + topic_id = conn.execute('SELECT id FROM topics WHERE content = (?);', + (topic_tag,)).fetchone()['id'] + conn.execute('INSERT INTO topic_cards (topic_id, card_id) VALUES (?,?)', + (topic_id, cat_id)) + conn.commit() conn.close() return redirect(url_for('home')) @@ -147,6 +155,7 @@ def edit(id): categories = conn.execute( 'SELECT category_name FROM categories;').fetchall() + topics = conn.execute('SELECT content FROM topics;').fetchall() if request.method == 'POST': content = request.form['content'] diff --git a/library.db b/library.db index 43fb888..9c019f7 100644 Binary files a/library.db and b/library.db differ