Skip to main content

PySynthData

A Rust-native library for generating synthetic relational datasets from a schema: real row generation with foreign keys, constraints, differential privacy support, and quality scoring.

What it is

PySynthData generates realistic synthetic relational data from a declarative schema. It ensures foreign keys point to valid parents, enforces constraints, scores data quality, and exports to common formats. Core generation and quality scoring run in Rust with a Python API.

Features / Highlights

  • Schema-driven generation: Define entities, fields, relationships, and constraints (YAML or Python API).
  • Relational integrity: Foreign keys are populated from existing parent rows in dependency order.
  • Constraint enforcement: Supports nullability, uniqueness, ranges, lengths, patterns, and enums.
  • Differential privacy: Laplace mechanism noise injection with a real ε-δ budget that prevents overspending.
  • Streaming generation: Generate large datasets in chunks to bound peak memory.
  • Quality scoring: Computes fidelity based on actual violations (not hardcoded).
  • Export formats: Pandas DataFrames, Parquet, and JSON.
  • Schema inference: Infer schemas from live Postgres, MySQL, or SQLite databases via SQLAlchemy.

Who it's for / Use cases

  • Testing and demos: Generate realistic relational fixtures without sharing production data.
  • Privacy-safe development: Create synthetic derivatives of sensitive data with differential privacy.
  • Database prototyping: Populate schemas with consistent relational data for development.
  • CI/testing: Produce deterministic, reproducible test datasets from versioned schemas.

What it is not

  • Not a full SDV replacement for all use cases: Focused on relational schema fidelity, constraints, and privacy primitives; advanced ML-based synthesis is out of scope.
  • Not compliance certification: Differential privacy is a technical primitive, not a guarantee of regulatory compliance.
  • Alpha maturity: Some bundled components exist in Rust but are not exposed through the Python API (see roadmap).

Project status

Version 0.5.0 (published to PyPI). Core pipeline (schema definition, row generation, FKs, constraints, quality scoring, exports, differential privacy, streaming, schema inference) is implemented and tested. See ROADMAP_HONEST.md for unexposed work and limitations.

Installation

pip install pysynthdata

With database schema inference support:

pip install pysynthdata[db]

Quick start

from pysynthdata import Schema, WorldGenerator

schema = Schema()
schema.add_entity("customers")
schema.add_field("customers", "id", "uuid", unique=True)
schema.add_field("customers", "name", "string")
schema.add_field("customers", "age", "int")
schema.add_field("customers", "status", "enum(active,suspended,closed)")
schema.add_constraint("range", "customers", "18-90", field="age")

schema.add_entity("orders")
schema.add_field("orders", "id", "uuid", unique=True)
schema.add_field("orders", "customer_id", "uuid")
schema.add_relationship("customers", "orders", "id", "customer_id", "1:n")

generator = WorldGenerator(schema)
world = generator.generate(num_records=1000, seed=42)

df = world.to_pandas("customers")
world.to_parquet("out/")
world.to_json("out/world.json")

print(world.fidelity_score)
print(world.quality_report)

Generation is deterministic: same schema + seed produces identical results. Foreign keys always reference valid parent rows.

Usage

From YAML

generator = WorldGenerator.from_yaml("examples/banking_schema.yaml")
world = generator.generate(num_records=5000, seed=7)

Schema inference from database

pysynthdata infer-schema --db-url "postgresql+psycopg://user:pass@host/dbname" \
    --table customers --output customers_schema.yaml

pysynthdata infer-schema --db-url "mysql+pymysql://user:pass@host/dbname" \
    --all-tables --output full_schema.yaml

Drivers (psycopg/psycopg2, pymysql) must be installed separately. Output YAML is compatible with Schema.from_yaml()/WorldGenerator.from_yaml().

Differential privacy

from pysynthdata import PrivacyBudget

budget = PrivacyBudget(epsilon=1.0, delta=1e-5)
private_world = generator.generate_private(num_records=1000, seed=42, budget=budget, epsilon=0.3)
print(private_world.privacy_report)
print(budget.remaining_epsilon)

Streaming generation

for entity_name, rows in generator.generate_streaming(num_records=5_000_000, seed=1, chunk_size=50_000):
    ...

generator.to_parquet_streaming(num_records=5_000_000, seed=1, out_dir="out/", chunk_size=50_000)

Data quality analysis

from pysynthdata import DataQualityAnalyzer

analyzer = DataQualityAnalyzer()
df = world.to_pandas("customers")
report = analyzer.analyze(df, entity_name="customers")
print(report)

Documentation

Part of the Mullassery open-source family:

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Metadata

Release files for pysynthdata 0.5.2

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

Source distribution (sdist)

Source distribution for pysynthdata 0.5.2
File Size Uploaded Provenance
pysynthdata-0.5.2.tar.gz 106.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pysynthdata 0.5.2
File Interpreter ABI Platform
pysynthdata-0.5.2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 1.1 MB

Release files / pysynthdata-0.5.2.tar.gz

Download URL pysynthdata-0.5.2.tar.gz
Size 106.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e8dd00b3cc268f22d63430184e284ae68eab888ab94c28be1a13f129907ba70c
BLAKE2b-256 checksum
How to use checksums
91217d3456916e43cbed49af5b46ba907371a42ef1103b0e732d11b81be74fea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / pysynthdata-0.5.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL pysynthdata-0.5.2-cp310-abi3-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cd592b76cfad7ac003a73b9a864dd9fa969a0854cece5db36db519f1d0e464a1
BLAKE2b-256 checksum
How to use checksums
2d278d7ea3d83bc37b49d9b68db182c8080d4bf0684634a93f0886241d88f548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for pysynthdata 0.5.2

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.

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