Search code examples
pythonsqldatabaseflask

The database model and the created database definition is different


The line below contains the definition for the database table Notes:

class Notes(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    title = db.Column(db.String(1000))
    description = db.Column(db.String(2000))
    owner = db.column(db.String(1000))
    shared_with = db.Column(db.String(2000))
    updated_by = db.Column(db.String(1000))
    date = db.Column(db.DateTime(timezone = True), default = func.now())

The below screenshot contains the result of the database definition:

The image shows that owner column is missing in the created database

The owner column is missing. I also tried to change the name of the column to see if it would work, but I had no luck.

It will be helpful if anyone knows why the owner column is missing


Solution

  • If that really is your code, you just have a typo:

        description = db.Column(db.String(2000))
        owner = db.column(db.String(1000))
    

    db.column vs db.Column. Fix the casing in the first and it should work.