# sqlalchemy.exc.DataError: (psycopg2.errors.StringDataRightTruncation) value too long for type character varying(50)

- **ID:** `python/sqlalchemy-exc-data-error-value-too-long`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Inserting a string that exceeds the maximum length defined in the database column (VARCHAR limit).

## Version Compatibility

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

## Workarounds

1. **Alter column to larger size** (90% success)
   ```
   Increase the column length via migration, e.g., ALTER TABLE users ALTER COLUMN name TYPE VARCHAR(100);
   ```
2. **Add input length validation** (85% success)
   ```
   Validate input length in application code before insertion, e.g., if len(name) > 50: raise ValueError.
   ```

## Dead Ends

- **Manually truncating the string** —  (60% fail)
- **Retrying without modification** —  (90% fail)
