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.1

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.1
File Size Uploaded Provenance
pysynthdata-0.5.1.tar.gz 106.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pysynthdata 0.5.1
File Interpreter ABI Platform
pysynthdata-0.5.1-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.1.tar.gz

Download URL pysynthdata-0.5.1.tar.gz
Size 106.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b7bb54adaa099b7325fba6dff5e6d3c609f492679b263ee9ae7f2bcc41630406
BLAKE2b-256 checksum
How to use checksums
0ab33cf02f02b6683e89f4b9085cb3b9ffdfe6653aac1ecda7fd8c904d14fb51
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL pysynthdata-0.5.1-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
ac5fe3a063e55da7601082d44073a5e82216112bc40860387c9c1209d478448d
BLAKE2b-256 checksum
How to use checksums
d36a0a282e79c984f07513ba4ecdd235c850c63c46018f0d58adc419f820bac3
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.1

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