{
  "id": "python/flask-sqlalchemy-no-application-found",
  "signature": "RuntimeError: The current Flask app is not registered with this 'SQLAlchemy' instance.",
  "signature_zh": "RuntimeError: 当前 Flask 应用未注册到此 'SQLAlchemy' 实例。",
  "regex": "RuntimeError:\\ The\\ current\\ Flask\\ app\\ is\\ not\\ registered\\ with\\ this\\ 'SQLAlchemy'\\ instance\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "db = SQLAlchemy() was created in a module but db.init_app(app) was never called, or a different app instance is active.",
  "root_cause_type": "generic",
  "root_cause_zh": "在模块中创建了 db = SQLAlchemy()，但从未调用 db.init_app(app)，或当前激活的是另一个 app 实例。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Instance still lacks the app binding.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Creates two instances; models attach to the wrong one.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "db = SQLAlchemy()\ndef create_app():\n    app = Flask(__name__)\n    db.init_app(app)\n    return app",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "app = create_app()\nwith app.app_context():\n    db.create_all()",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-06",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}