-1

    from flask import Flask,render_template,url_for
    from flask_sqlalchemy import sqlalchemy
    from datetime import datetime
    
    app=Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///test.db'
    db=sqlalchemy(app)
    
    class Todo(db.Model):
        id=db.Column(db.Interger,primary_key=True)
        content =db.Column(db.String(200),nullable=False)
        completed=db.Column(db.Integer,default=0)
        data_created=db.Column(db.DataTime,default=datetime.utcnow)
    
        def __repr__(self):
            return '<Task %r>' % self.id
    
    @app.route('/')
    def index():
        return render_template('index.html')
    
    if __name__=="__main__":
        app.run(debug=True)

I am getting this error :
Traceback (most recent call last):
File "stdin", line 1, in module
File "D:\My Programs\Flask_intro\app.py", line 7, in db=sqlalchemy(app)
TypeError: 'module' object is not callable

Ragul R
  • 59
  • 1
  • 1
  • 8

1 Answers1

0

It's like %s to print str

The difference between %r and %s is, %r calls the repr() method and %s calls the str() method. Both of these are built-in Python functions.

The repr() method returns a printable representation of the given object. The str() method returns the "informal" or nicely printable representation of a given object.

Kuldeep Singh Sidhu
  • 3,748
  • 2
  • 12
  • 22