# sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "email" violates not-null constraint

- **ID:** `python/sqlalchemy-flush-error-null-violation`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to insert or update a row where a NOT NULL column is not provided a value, causing a database integrity error.

## Version Compatibility

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

## Workarounds

1. **Provide required values explicitly** (95% success)
   ```
   Ensure all NOT NULL columns are assigned values before flush/commit, e.g., user.email = 'user@example.com'.
   ```
2. **Alter column to allow NULL** (80% success)
   ```
   Modify the database schema to allow NULL if appropriate, using ALTER TABLE or migration.
   ```

## Dead Ends

- **Adding default=None to column** —  (50% fail)
- **Calling flush() instead of commit()** —  (40% fail)
