# UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 10: ordinal not in range(128)

- **ID:** `python/sqlalchemy-unicode-encode-error`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Python 2 or misconfigured Python 3 environment trying to encode non-ASCII characters.

## Version Compatibility

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

## Workarounds

1. **Ensure database connection uses UTF-8.** (95% success)
   ```
   engine = create_engine('postgresql://user:pass@localhost/dbname?client_encoding=utf8')
   ```
2. **Encode strings to UTF-8 before storing.** (90% success)
   ```
   name = 'José'.encode('utf-8').decode('utf-8')  # Ensure proper encoding
   ```

## Dead Ends

- **Replacing characters with ASCII equivalents manually.** — Not scalable; data loss. (60% fail)
- **Setting sys.setdefaultencoding('utf-8') in Python 2.** — Deprecated and may cause side effects. (70% fail)
