problem with connecting flask app with sqlite

43 views Asked by At

i am using SQLAlchemy python module to connect flask app with sqlite database(db browser for sqlite) but i dont know how to connect it. i have cloned a repo. Please tell me if i have to do any extra step or something. i have imported the .db file present in the repo to db browser but stuck here and getting this error

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user
[SQL: SELECT user.id AS user_id, user.username AS user_username, user.email AS user_email, user.image_file AS user_image_file, user.password AS user_password
FROM user
WHERE user.username = ?
LIMIT ? OFFSET ?]
[parameters: ('21509016', 1, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

please help me solve this error guys. you can view main.py code in github and help me i desperate to run this project!!!

i tried searching for the solution using gemini and chatgpt but it didn't gave up to the mark answers!

1

There are 1 answers

0
arshovon On

The error indicates that you need to create the database instances before running the app.

I am able to fix that and create new user and login the user by creating the tables before running the app in the run.py file:

from Main import app, db

if __name__ == '__main__':
    with app.app_context():
        db.create_all()   
    app.run(debug=True)

Demo:

running the app

Disclaimer: The project seems like a toy project and has a lot of bugs here and there (e.g. fixed dataset path).