# sqlalchemy.exc.MultipleResultsFound: Multiple rows were found for one()

- **ID:** `python/sqlalchemy-query-too-many-rows`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using the one() method on a query that returns more than one row, which expects exactly one.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Use one_or_none() to handle zero or one result** (95% success)
   ```
   user = session.query(User).filter_by(id=user_id).one_or_none()
if user is None:
    # Handle not found
    pass
   ```
2. **Use scalar() for single column queries** (90% success)
   ```
   count = session.query(func.count(User.id)).scalar()
   ```

## Dead Ends

- **Using first() instead without checking** — first() returns None if no rows, masking potential logic errors. (60% fail)
- **Ignoring the error and assuming one row** — The error will still occur. (100% fail)
