Я новичок в Python. Я использую Pycharm и Flask для создания веб-приложения. Я написал следующий код, но он дает мне ошибку. Пожалуйста, помогите, я хочу создать базу данных.
from flask import Flask, render_template
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.Colmnn(db.Interger, default=0)
date_created = db.Column(db.DateTime, 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)
'''
Ошибка:
"C:\Users\Takunda Mafuta\AppData\Local\Programs\Python\Python38-32\python.exe" "C:/Users/Takunda Mafuta/Videos/lgT Personal Development/Data Science/Python/Tutorials/FreeCodeCamp/Exercise/TaskMaster.py"
Traceback (most recent call last):
File "C:/Users/Takunda Mafuta/Videos/lgT Personal Development/Data Science/Python/Tutorials/FreeCodeCamp/Exercise/TaskMaster.py", line 2, in <module>
from flask_sqlalchemy import SQLAlchemy
File "C:\Users\Takunda Mafuta\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask_sqlalchemy\__init__.py", line 13, in <module>
import sqlalchemy
File "C:\Users\Takunda Mafuta\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\__init__.py", line 8, in <module>
from . import util as _util # noqa
File "C:\Users\Takunda Mafuta\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
from ._collections import coerce_generator_arg # noqa
File "C:\Users\Takunda Mafuta\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>
from .compat import binary_types
File "C:\Users\Takunda Mafuta\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Process finished with exit code 1