Skip to main content

postgres-data-sanitizers

PostgreSQL-specific data sanitization (null chars, surrogates).

Installation

pip install postgres-data-sanitizers

Usage

from postgres_data_sanitizers import (
    escape_null_chars,
    sanitize_dict_for_postgres,
    validate_postgres_text,
    contains_surrogates
)

# Escape null characters in strings
safe_text = escape_null_chars("hello\x00world")  # "hello\\u0000world"

# Sanitize dictionaries for JSONB storage
data = {"key": "value\x00with\x00nulls"}
safe_data = sanitize_dict_for_postgres(data)

# Validate text fields
text = validate_postgres_text("user input\x00")

# Check for surrogate characters
has_surrogates = contains_surrogates(text)

Features

  • ✅ Escapes null characters (preserves data)
  • ✅ JSONB-safe dictionary sanitization
  • ✅ Surrogate character detection
  • ✅ Zero dependencies
  • ✅ Prevents database crashes

Why This Matters

PostgreSQL rejects null characters (\x00) in TEXT/VARCHAR/JSONB fields, causing:

asyncpg.exceptions.UntranslatableCharacterError

This library escapes rather than removes null characters, preserving data integrity.

License

MIT

Metadata

Release files for postgres-data-sanitizers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postgres-data-sanitizers 0.1.0
File Size Uploaded Provenance Actions
postgres_data_sanitizers-0.1.0.tar.gz 3.8 kB Without provenance Details for postgres_data_sanitizers-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for postgres-data-sanitizers 0.1.0
File Interpreter ABI Platform Actions
postgres_data_sanitizers-0.1.0-py3-none-any.whl Python 3 none any Details for postgres_data_sanitizers-0.1.0-py3-none-any.whl

Total release size: 9.0 kB

Release files / postgres_data_sanitizers-0.1.0.tar.gz

Download URL postgres_data_sanitizers-0.1.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
617bb7c66c01668c212d934f244809c7fb8a996b3375d09340d559a5f3c850a2
BLAKE2b-256 checksum
How to use checksums
fdef085e9a4c8bf93c87aedb16450a82df16c5f0b0aaa7ffde91e35aa7f58693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / postgres_data_sanitizers-0.1.0-py3-none-any.whl

Download URL postgres_data_sanitizers-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08bab08bc34f8cf19c15e88567171804fc69307fec1ca1c29e83eadd8755bc4f
BLAKE2b-256 checksum
How to use checksums
658c10772955acf436590c355f6cd4b9e6dbba790834ee53d7371907e7db7d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for postgres-data-sanitizers 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page