# sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1366, "Incorrect string value: '\xF0\x9F\x98\x80' for column 'message' at row 1")

- **ID:** `python/sqlalchemy-mysql-charset-issue`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The database/table/column character set is not utf8mb4, which cannot store 4-byte Unicode characters like emojis.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.4.x | active | — | — |
| 2.0.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Use charset='utf8mb4' in the connection URL: engine = create_engine('mysql+pymysql://user:pass@host/db?charset=utf8mb4')
   ```
2. **** (85% success)
   ```
   Alter the table to use utf8mb4: ALTER TABLE messages CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
   ```

## Dead Ends

- **** — utf8 in MySQL is actually utf8mb3, which still doesn't support 4-byte characters. (90% fail)
- **** — Corrupts the data. (80% fail)
