{
  "id": "python/sqlalchemy-missing-sessionmaker",
  "signature": "AttributeError: module 'sqlalchemy.orm' has no attribute 'sessionmaker'",
  "signature_zh": "AttributeError: 模块 'sqlalchemy.orm' 没有属性 'sessionmaker'",
  "regex": "AttributeError:\\ module\\ 'sqlalchemy\\.orm'\\ has\\ no\\ attribute\\ 'sessionmaker'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Importing sessionmaker incorrectly, e.g., from sqlalchemy.orm import sessionmaker is correct, but some may do from sqlalchemy import orm and then orm.sessionmaker which doesn't exist.",
  "root_cause_type": "generic",
  "root_cause_zh": "错误地导入 sessionmaker，例如 from sqlalchemy.orm import sessionmaker 是正确的，但有些人可能使用 from sqlalchemy import orm 然后 orm.sessionmaker，这不存在。",
  "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": "sessionmaker is not in the top-level sqlalchemy namespace; it's in sqlalchemy.orm.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The correct name is sessionmaker (no underscore).",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "Import correctly: from sqlalchemy.orm import sessionmaker",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 1.0,
      "how": "Use Session = sessionmaker(bind=engine) after correct import.",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}