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

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

## Root Cause

尝试插入或更新记录时，非空字段未提供值。

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   在插入前检查并填充所有非空字段。
   ```
2. **** (85% success)
   ```
   在模型中使用 default 或 server_default 提供默认值。
   ```

## Dead Ends

- **** — 在数据库中删除非空约束，但破坏了数据完整性。 (80% fail)
- **** — 在应用层忽略该字段，但会持续报错。 (70% fail)
