Package: dammy
dammyGenerate fake/dummy data for any purposeTable of contentsIntroductionFeaturesExampleInstallationRelease historyIntroductiondammy is a powerful and simple tool to generate fake data. You can use it to mock classes, populate databases and and much more.
You can check the full documentationhere.FeaturesGenerate anything within the set of prebuilt objects (Person names, country names, car manufacturers and models, random dates...)Compose more complex data easily (Full profiles, complete databases, )The possibility to expand the previous set with little to no codeCompletely intuitive, you will learn to use it in less than 10 minutesExport the generated data to SQLExampleIf you wanted to generate 1000 random people, just define what a person looks like and dammy will handle the restfromdammyimportEntityGeneratorfromdammy.functionsimportcastfromdammy.stdlibimportRandomName,RandomString,RandomDateTime,RandomInteger,CountryNameclassPerson(EntityGenerator):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 peopleforiinrange(0,1000):print(Person())Which will output:{'identifier': 1, 'uid': '9XCha', 'first_name': 'ZAYN', 'blood': 'A+', 'birthday': '24/01/1982', 'favorite_number': 5, 'age': 38, 'country': 'Denmark'}
{'identifier': 2, 'uid': 'bbYbw', 'first_name': 'MALIHA', 'blood': 'AB+', 'birthday': '01/12/1981', 'favorite_number': 1, 'age': 38, 'country': 'Syrian Arab Republic'}
{'identifier': 3, 'uid': 'aGF49', 'first_name': 'ANGEL', 'blood': 'AB+', 'birthday': '18/08/1992', 'favorite_number': 1, 'age': 27, 'country': 'Macedonia, the Former Yugoslav Republic of'}
{'identifier': 4, 'uid': 'Lcr0J', 'first_name': 'REUBEN', 'blood': '0-', 'birthday': '07/11/1997', 'favorite_number': 4, 'age': 22, 'country': 'Dominican Republic'}
{'identifier': 5, 'uid': 'P7mD4', 'first_name': 'MAMADOU', 'blood': 'A+', 'birthday': '02/01/1987', 'favorite_number': 7, 'age': 33, 'country': 'Palau'}
{'identifier': 6, 'uid': 'ykdeL', 'first_name': 'BATSHEVA', 'blood': 'A+', 'birthday': '11/01/1983', 'favorite_number': 5, 'age': 37, 'country': 'Seychelles'}
{'identifier': 7, 'uid': 'h9HjQ', 'first_name': 'JIMENA', 'blood': 'A-', 'birthday': '23/10/1985', 'favorite_number': 0, 'age': 34, 'country': 'China'}
{'identifier': 8, 'uid': 'rjt92', 'first_name': 'YERIK', 'blood': 'AB+', 'birthday': '29/10/1991', 'favorite_number': 5, 'age': 28, 'country': 'Libya'}
{'identifier': 9, 'uid': 'vL0DE', 'first_name': 'YISRAEL', 'blood': 'AB+', 'birthday': '25/03/1989', 'favorite_number': 8, 'age': 30, 'country': 'Spain'}
{'identifier': 10, 'uid': 'CsrhX', 'first_name': 'JOSHUA', 'blood': 'AB+', 'birthday': '20/09/1999', 'favorite_number': 1, 'age': 20, 'country': 'Svalbard and Jan Mayen'}
...It also supports relationships between tables, so you can generate data to populate databasesfromdammyimportEntityGeneratorfromdammy.dbimportAutoIncrement,PrimaryKey,ForeignKeyfromdammy.stdlibimportRandomName,RandomString,RandomDateTime,RandomInteger,CountryName# Define what a person looks likeclassPerson(EntityGenerator):id_pk=PrimaryKey(id=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 likeclassCar(EntityGenerator):id_pk=PrimaryKey(id=AutoIncrement())manufacturer_name=CarBrand()model=CarModel(car_brand=manufacturer_name)owner=ForeignKey(Person,'identifier')And the data can be exported to SQLfromdammyimportDatasetGenerator# Generate a dataset with 20000 cars and 94234 peopledataset=DatasetGenerator((Car,20000),(Person,94234)).generate()dataset.get_sql(save_to='cars_with_owners.sql')InstallationTo install the latest stable release of dammy using pippip install dammyYou can also install the latest development release by cloning the repository and installing it with pipgit clone https://github.com/ibonn/dammy.git dammy
cd dammy
pip install -e .Release history1.1.0Iterators added1.0.0Semantic versioning used from now onDocumentation fixedMinor code changes (duplicated code removed...)0.1.3Code refactoredAll binary operations made possible between BaseGenerator objectsBaseDammy renamed to BaseGeneratorEntityGenerator renamed to OperationResultDammyEntity renamed to EntityGeneratorEverything inherits from BaseGeneratorRemoved DatabaseConstraintAdded UNIQUE constraint supportDatasets can now be exported to JSONEntities can now be exported to JSON and CSVdammy.stdlib expanded with new built-in generators0.1.2Documentation improvedDatasetGenerator moved from main to dbMinor bugs fixed0.1.1Can get attributes of entitiesCan call methods on entitiesAbility to perform operations addedCode improvedDocstrings added0.0.3Fixed import bug in stdlib0.0.1First release