I have issues with my code, trying to setup SQLAlchemy database in flask using python. Code:
Thanks for the help.
Tried to reinstall SQLAlchemy.
I'm using a corporate laptop, shouldn't be a problem?
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.Integer, primary_key=True)
content = db.Column(db.String(200), nullable=False)
date_created = db.Column(db.DateTime, default=datetime
def __repr__(self):
return '<Task %r>' % self.id
@app.route('/', methods=['POST', 'GET'])
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)
(env) C:\Users\rodrigs\Documents\PythonFlaskApp>app.py
C:\Users\rodrigs\Documents\PythonFlaskApp\env\lib\site-packages\flask_sqlalchemy\__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
File "C:\Users\rodrigs\Documents\PythonFlaskApp\app.py", line 9, in <module>
class Todo(db.Model):
File "C:\Users\rodrigs\Documents\PythonFlaskApp\app.py", line 13, in Todo
date_created = db.Column(db.dateTime, default=datetime.utcnow)
AttributeError: 'SQLAlchemy' object has no attribute 'dateTime'