Relational data generator that creates meaningful test data with referential integrity
Project description
Generated Data That Makes Sense (GDTMS)
A Python library for generating realistic, relational test data with referential integrity. GDTMS creates meaningful data for database testing, development, and prototyping by maintaining relationships between tables and generating contextually appropriate values.
Features
- Relational data generation with foreign key relationships
- Multiple data types including names, emails, addresses, phone numbers, dates, and more
- Composite data types for complex field generation
- Unique constraints support to prevent duplicate values
- Self-referencing tables for hierarchical data structures
- MySQL output format with proper SQL syntax
- Configurable record counts per table
- Null value support with configurable probability
Installation
pip install generated-data-that-makes-sense
Quick Start
from gdtms.entities.schema import Schema
from gdtms.entities.table import Table
from gdtms.entities.field import Field
from gdtms.data_types.autoincrement import Autoincrement
from gdtms.data_types.first_name import FirstName
from gdtms.data_types.last_name import LastName
from gdtms.data_types.email import Email
from gdtms.views.mysql import Mysql
# Create a schema
schema = Schema()
# Create a users table
users_table = Table(name="users", num_records_to_generate=10)
users_table.add_fields([
Field("id", Autoincrement()),
Field("first_name", FirstName()),
Field("last_name", LastName()),
Field("email", Email())
])
schema.add_table(users_table)
# Generate SQL output
view = Mysql()
sql_output = schema.dump(view)
print(sql_output)
Supported Data Types
Autoincrement- Auto-incrementing integersFirstName- Realistic first namesLastName- Realistic last namesEmail- Valid email addressesPhoneNumber- Formatted phone numbersAddress- Street addressesCity- City namesZipPostal- ZIP/postal codesDate- Date valuesNumber- Numeric rangesUrl- Valid URLsDomainName- Domain namesAdjective- Descriptive adjectivesNoun- Common nounsVerb- Action verbsHardcodedValue- Fixed valuesReference- Foreign key relationshipsComposite- Combinations of multiple data types
Advanced Usage
Creating Related Tables
# Create parent table
countries = Table(name="countries", num_records_to_generate=5)
countries.add_fields([
Field("id", Autoincrement()),
Field("name", Noun())
])
# Create child table with foreign key
users = Table(name="users", num_records_to_generate=20)
users.add_fields([
Field("id", Autoincrement()),
Field("country_id", Reference(countries)),
Field("name", FirstName())
])
Unique Constraints
from gdtms.entities.unique_key import UniqueKey
username_field = Field("username", Email())
users_table.add_field(username_field)
users_table.add_unique_key(UniqueKey([username_field]))
Composite Data Types
from gdtms.data_types.composite import Composite
# Generate questions like "What red car do you drive?"
question_field = Field("question", Composite([
HardcodedValue("What"),
Adjective(),
Noun(),
Verb(),
HardcodedValue("?")
]))
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file generated_data_that_makes_sense-1.0.0.tar.gz.
File metadata
- Download URL: generated_data_that_makes_sense-1.0.0.tar.gz
- Upload date:
- Size: 696.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa8611b7ca3e0f9ecaa0a0da45691a0b72376a4ccb15c62e6b93ae3f3b1326c
|
|
| MD5 |
20aaca43e26c437d36e6c6ae87b20383
|
|
| BLAKE2b-256 |
dfff4ee307ad337e93e5180da6eab08ad48882da8f841a54316ef338d40d3d0c
|
File details
Details for the file generated_data_that_makes_sense-1.0.0-py3-none-any.whl.
File metadata
- Download URL: generated_data_that_makes_sense-1.0.0-py3-none-any.whl
- Upload date:
- Size: 712.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb81848b9a86039b3a360fb5ad0a56ffff19768c0c85e6691504eb63e223fe1
|
|
| MD5 |
e6eb07630c18b88fb2db9e0ab918f1ae
|
|
| BLAKE2b-256 |
559037a7afbec1d2e8fcca4133e6ae0c662cd077567cb9160da07cb47c015f10
|