我想用 SQLAlchemy 连接 Postgres 数据库。我安装了神经病2。但是,我得到了错误 sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres
。如何将 SQLAlchemy 配置为连接到 PostgreSQL?
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "postgres://username@localhost:5432/template1"
db = SQLAlchemy(app)