我总是犯同样的错误。我已经安装了所有我能安装的,比如:'pip install flask\u sqlalchemy'和'pip install sqlalchemy'等等,但是它仍然给我同样的错误。
我安装的软件包
我的代码:`
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' # load the configuration of choice
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Books(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(120), unique=True, nullable=False)
author = db.Column(db.String(120), unique=True, nullable=False)
rating = db.Column(db.Float(10), unique=True, nullable=False)
db.create_all()
new_book = Books(id=1, title="Harry Potter", author="J. K. Rowling", rating=9.3)
db.session.add(new_book)
db.session.commit()`
暂无答案!
目前还没有任何答案,快来回答吧!