Skip to main content

Simplify database population with dummy data

Project description

GitHub top language Documentation Status Travis (.org) Codacy Badge Maintainability PyPI download month PyPI download week PyPI download day

dammy

Populate your database with dummy data

Table of contents

Introduction

dammy is a powerful and simple tool to populate your database with dummy data with a few lines of code. You can check the full documentation here.

Features

  • Great simplicity
  • A set of prebuilt objects (Person names, country names, car manufacturers and models, random dates...)
  • The possibility to expand the previous library
  • Generate datasets and export them to SQL

Example

If you wanted to generate 1000 random people, just define what a person looks like and dammy will handle the rest

from dammy import DammyEntity
from dammy.stdlib import RandomName, RandomString, RandomDateTime, RandomInteger, CountryName

class Person(DammyEntity):
    first_name = RandomName().upper()
    password = RandomString(5)
    birthday = RandomDateTime(start=datetime(1980, 1, 1), end=datetime(2000, 12, 31), date_format='%d/%m/%Y')
    favorite_number = RandomInteger(0, 10)
    age = cast((datetime.now() - birthday).days / 365.25, int)
    country = CountryName()

# Generate 1000 random people
for i in range(0, 1000):
    print(Person())

It also supports relationships between tables

from dammy import DammyEntity
from dammy.db import AutoIncrement, PrimaryKey, ForeignKey
from dammy.stdlib import RandomName, RandomString, RandomDateTime, RandomInteger, CountryName

# Define what a person looks like
class Person(DammyEntity):
    identifier = PrimaryKey(AutoIncrement())
    first_name = RandomName().upper()
    password = RandomString(5)
    birthday = RandomDateTime(start=datetime(1980, 1, 1), end=datetime(2000, 12, 31), date_format='%d/%m/%Y')
    favorite_number = RandomInteger(0, 10)
    age = cast((datetime.now() - birthday).days / 365.25, int)
    country = CountryName()

# Define what a car looks like
class Car(DammyEntity):
    identifier = PrimaryKey(AutoIncrement())
    manufacturer_name = CarBrand())
    model = CarModel(car_brand=manufacturer_name)
    owner = ForeignKey(Person, 'identifier')

And data can be exported to SQL

from dammy import DatasetGenerator

# Generate a dataset with 20000 cars and 94234 people
dataset = DatasetGenerator((Car, 20000), (Person, 94234))
dataset.get_sql(save_to='cars_with_owners.sql')

Installation

To install the latest release of dammy using pip run

pip install dammy

Release history

  • 0.1.2
    • Documentation improved
    • DatasetGenerator moved from main to db
    • Minor bugs fixed
  • 0.1.1
    • Can get attributes of entities
    • Can call methods on entities
    • Ability to perform operations added
    • Code improved
    • Docstrings added
  • 0.0.3
    • Fixed import bug in stdlib
  • 0.0.1
    • First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dammy-0.1.2.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

dammy-0.1.2-py3-none-any.whl (34.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page