flask-sqlalchemy icon indicating copy to clipboard operation
flask-sqlalchemy copied to clipboard

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

Open FossenWang opened this issue 6 months ago • 1 comments

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:

  • Python version: 3.9.12
  • Flask-SQLAlchemy version: 3.0.3
  • SQLAlchemy version: 2.0.22

FossenWang avatar Dec 27 '23 06:12 FossenWang

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

pamelafox avatar Dec 27 '23 14:12 pamelafox