{"id":28305534,"url":"https://github.com/hernantz/spamdb","last_synced_at":"2025-07-26T00:09:21.053Z","repository":{"id":5877556,"uuid":"7095111","full_name":"hernantz/spamdb","owner":"hernantz","description":"A python peewee based lib to spam / fill databases with random test data","archived":false,"fork":false,"pushed_at":"2012-12-10T16:16:08.000Z","size":168,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-31T11:46:23.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hernantz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-10T14:56:52.000Z","updated_at":"2013-10-13T19:35:16.000Z","dependencies_parsed_at":"2022-08-06T19:00:56.510Z","dependency_job_id":null,"html_url":"https://github.com/hernantz/spamdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hernantz/spamdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernantz%2Fspamdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernantz%2Fspamdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernantz%2Fspamdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernantz%2Fspamdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hernantz","download_url":"https://codeload.github.com/hernantz/spamdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernantz%2Fspamdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261056458,"owners_count":23103440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-24T02:12:49.252Z","updated_at":"2025-07-26T00:09:20.826Z","avatar_url":"https://github.com/hernantz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"spamdb\n======\n\nSpamdb is a python class that acts like a container (think a list) of peewee models.\nIt also provides a bunch of methods to spam every database field of your model with a \nrandomly generated value. Each method can be overrided with your own spam functions.\n\nThe simplest use case would be:\n\n    from spamdb import Spamdb     \n    from myapp import models\n\n\n    # spam all User and Blog db fields and save them to the database\n    Spamdb(models.User, models.Blog).run()\n\nThe way Spamdb works is as follows:\n\n1. Iterate over self contained models (passed in the _init__ or append)\n2. Get a list of peewee.Field type attributes of a models and iterate over this list\n3. For each field, try to spam it in this order: \n    * Check if it allows null values.  If so randomly determine to leave the field null or not.\n    * Check wether the field  has gotten a choices attribute. If so pick one of these.\n    * Check for a strict spam handler for the current field. If found one, call it.\n    * Check for a global spam handler for the current field's type. If found one, call it.\n    * If none of the above options worked, ignore the current field.\n4. Save an instance of the model with the spammed values.\n\nOverride the default spam functions with your own\n\n\timport spamdb\n\timport myapp.models\n\timport peewee\n\n\tsdb = spamdb.Spamdb()\n\n\t@sdb.global(peewee.CharField)\n\tdef spam_charfield(field):\n\t\treturn \"Hello kitty\"\n\n\t@sdb.strict(models.User.name):\n\tdef spam_username(field): return \"My custom username\" sdb.append(models.User) \n\tif __name__ == '__main__':\n\t\tsdb.run(iterations=100)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernantz%2Fspamdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhernantz%2Fspamdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernantz%2Fspamdb/lists"}