Hello I'm trying to create a DB model for my flask app using flask_sqlchemy. But getting this attribute error where it it says 'SQLAlchemy' object has no attribute 'Cloumn'.
Here's my code:
from flask_sqlalchemy import SQLAlchemy
from flask import Flask, request
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///Cbot.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Initializing DB
db = SQLAlchemy(app)
class bot(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Cloumn(db.String(200), nullable=False)
dateCreated = db.Cloumn(db.DateTime, default=datetime.utcnow)
def __repr__(self):
return '<Name %r>' % self.id
Thanks and Any help would be appreciated.
Fixed Made a typo in column:)
CodePudding user response:
You have a typo:
name = db.Cloumn(db.String(200), nullable=False)
dateCreated = db.Cloumn(db.DateTime, default=datetime.utcnow)
Cloumn
-> Column