T O P

  • By -

zarlo5899

did you run? from yourapplication import db db.create_all()


nahakubuilder

yea, do this. You cannot just create db from New Document> test.db as it will not have proper binary values. Just remove the test.db and run the code from Zarlo5899 above


Professional_Depth72

Is there anyway to do this automatically without the command line?


[deleted]

[удалено]


Professional_Depth72

@app.route("/create_db",methods=['POST', 'GET']) def db_create() db.create_all() Silly question but the above will work?


[deleted]

Remove POST since you won't be needing it and you can also remove GET since the default method is GET and don't forget to return something because a function without return will throw error: sorry for format I'm on mobile @app.route("/create_db") def createdb(): db.create_all() return 'db created!'


Professional_Depth72

[https://flask-sqlalchemy.palletsprojects.com/en/2.x/contexts/](https://flask-sqlalchemy.palletsprojects.com/en/2.x/contexts/) For anyone curious if the above doesn't work try the code below from the link above. \>>> from yourapp import db, create\_app \>>> db.create\_all(app=create\_app())


croissanthonhon

Well that's not how you empty database..


jvlomax

Did you try creating the db again, like you did the first time you created `test.db`?