{
  "id": "python/sqlalchemy-missing-session-bind",
  "signature": "sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper, SQL expression, or this Session.",
  "signature_zh": "SQLAlchemy 未绑定执行错误：无法找到在映射器、SQL 表达式或此会话上配置的绑定。",
  "regex": "sqlalchemy\\.exc\\.UnboundExecutionError:\\ Could\\ not\\ locate\\ a\\ bind\\ configured\\ on\\ mapper,\\ SQL\\ expression,\\ or\\ this\\ Session\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "会话或引擎未正确绑定到数据库，无法执行 SQL。",
  "root_cause_type": "generic",
  "root_cause_zh": "会话或引擎未正确绑定到数据库，无法执行 SQL。",
  "versions": [
    {
      "version": "1.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "尝试使用默认会话，但未配置引擎。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "在会话中手动添加 bind，但可能与其他配置冲突。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "创建会话时绑定引擎：Session = sessionmaker(bind=engine)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "在查询时指定 bind：session.execute(stmt, bind=engine)",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-05-16",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}