pallets-eco / flask-sqlalchemy

Adds SQLAlchemy support to Flask
https://flask-sqlalchemy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
4.25k stars 902 forks source link

`SQLAlchemy.__repr__` raises `KeyError` when the default engine is not set. #1295

Open FossenWang opened 11 months ago

FossenWang commented 11 months ago
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()
app = Flask(__name__)
app.config['SQLALCHEMY_BINDS'] = {'x': 'sqlite:///:memory:'}

db.init_app(app)
with app.app_context():
    print(db)

# KeyError: None

Environment:

pamelafox commented 11 months ago

Thanks for the report! I've proposed a fix at https://github.com/pallets-eco/flask-sqlalchemy/pull/1296/files