テーブル作成ができません。
Pythonでアプリを作成しているのですが、
localhostに接続すると、テーブルがないと返ってきてしまいます。
「sqlite3.OperationalError: no such table: entries」
昨日まではしっかりと動いていて、問題はなかったのですが、
もともとあったflaske.dbのファイルを誤って手書きで編集し、それを保存してしまってから、エラーが返ってくるようになったので新たにdbファイルを作成しました。
(それがいけなかったのですが...)
schema.sqlでcreate tableをしているので作成できていると思ったのですが、
何をどう直しても上手くいきません。
何か解決策がありましたらご教示いただきたいです。
よろしくお願いします。
python
1DATABASE = 'flaskr.db' 2DEBUG = True 3SECRET_KEY = 'development key' 4USERNAME = 'admin' 5PASSWORD = 'admin' 6 7def connect_db(): 8 return sqlite3.connect(app.config['DATABASE']) 9 10def init_db(): 11 with closing(connect_db()) as db: 12 c = db.cursor() 13 with app.open_resource('schema.sql') as f: 14 db.cursor().executescript(f.read()) 15 db.commit()
sql
1drop table if exists entries; 2create table entries ( 3 id integer primary key autoincrement, 4 title string not null, 5 text string not null 6);
あなたの回答
tips
プレビュー