0

I am trying to make a simple web app and trying to link it to sql lite database. I tried following the documentation and wrote the following code to make a database in the flask app

from flask import Flask , render_template
from flask_sqlalchemy import SQLAlchemy 
from datetime import datetime 

app = Flask(__name__) 

app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:////todo.db"  
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app) 

class Todo(db.Model)  :
    sno = db.Column(db.Integer , primary_key= True) 
    title =  db.Column(db.String(200) , nullable = False) 
    desc [enter image description here](https://i.stack.imgur.com/ey73y.png)= db.Column(db.String(500) , nullable = False) 
    date_created = db.Column(db.DateTime , default = datetime.utcnow)

    def __repr__(self ) -> str : 
        return f"{self.sno} - {self.title}"


@app.route('/') 
def helloWorld()  :
    return render_template("index.html") 

@app.route('/products')  
def products() : 
    return "this is the products page"
 
if __name__ == "__main__"  :
    app.run(debug = True , port = 8000 )  

Now after saving this file and opening the python interpreter I am facing an error like this

enter image description here

I cant figure out anything after searching on the web for a long time . Can somebody point me in the right direciton ? Thanks

davidism
  • 121,510
  • 29
  • 395
  • 339
Auxer
  • 15
  • 3

0 Answers0