postgres-data-sanitizers¶
PostgreSQL data sanitization: null character escaping, surrogate detection, JSONB-safe dictionaries.
Installation¶
pip install postgres-data-sanitizers
Public API¶
Function |
Purpose |
|---|---|
|
Escape |
|
Reverse escape |
|
Recursively escape nulls in dict (JSONB) |
|
Reverse dict escape |
|
Validate and escape text for storage |
|
Detect UTF-8 surrogate characters |
Usage¶
from postgres_data_sanitizers import sanitize_dict_for_postgres
safe = sanitize_dict_for_postgres({"bio": "text\x00with\x00nulls"})
# nulls escaped for PostgreSQL JSONB storage