fillmydb
Fill your database with mocked instances.
Wrap you ORM model into a ModelWrapper, specify how your fields should look like and then generate how many instances you want of each model.
Installation
pip install fillmydb[peewee] if you plan to use it with peewee models
pip install fillmydb[django] if you plan to use it with djanog models (not implemented yet)
pip install fillmydb[sqlalchemy] if you plan to use it with sqlalchemy models (not implemented yet)
Usage with fake-factory
Generating instances for a single model:
import faker factory = faker.Factory.create() wrapper = ModelWrapper(TestModel) wrapper[TestModel].client_name = FieldSpec(factory.name) wrapper[TestModel].description = FieldSpec(factory.text) wrapper[TestModel].password_hash = FieldSpec(factory.binary, length=25) wrapper[TestModel].email = FieldSpec(factory.email) wrapper[TestModel].visits = FieldSpec(factory.pyint) item = wrapper.generate(100)
Generating instances for multipe models:
from tests.models import User, Post, Like import faker factory = faker.Factory.create() wrapper = ModelWrapper(User, Like, Post) wrapper[User].name = FieldSpec(factory.name) wrapper[User].username = FieldSpec(factory.user_name) wrapper[User].description = FieldSpec(factory.text) wrapper[User].password_hash = FieldSpec(factory.binary, length=25) wrapper[User].email = FieldSpec(factory.email) wrapper[User].visits = FieldSpec(factory.pyint) wrapper[Post].title = FieldSpec(lambda _: "test", 1) wrapper[Post].text = FieldSpec(factory.text) # generating 10 users, 100 likes and 20 posts wrapper.generate(10, 100, 20)
General workflow
Pseudo-code:
initial_to_order_queue()
while models_to_process():
model = get_next_model()
if model.has_unresolved_dependency():
push_back_to_queue(model)
# process model
for _ in range(number_of_instances):
for field in model.fields():
# resolve_field(field)
if field == ForeignKey:
field = get_random_ref_model_instance()
else:
field = resolve_normal()
mark_as_processed(model)
Metadata
Release files for fillmydb 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fillmydb-0.1.0.zip | 9.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fillmydb-0.1.0.win-amd64.zip | Details |
Total release size: 31.7 kB
Release files / fillmydb-0.1.0.zip
| Download URL | fillmydb-0.1.0.zip |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3e2341c71431f280b632bf9de85289e6e6f0583e431f4a014914c1c28615fc0
|
|
BLAKE2b-256 checksum How to use checksums |
dc8504c983b8fd8d98b2339dc108bf7bae7e856a606fb6e9f463a035e70950fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / fillmydb-0.1.0.win-amd64.zip
| Download URL | fillmydb-0.1.0.win-amd64.zip |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9422eb5c86c50b53fa9bfebac9341dda9ad633e21fa6c675f3d6a6a31df4742
|
|
BLAKE2b-256 checksum How to use checksums |
5bbcf855b377bbf969b4a857ac48e33f67d1270f80b0e3f1f8d6ef3b0879b581
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for fillmydb 0.1.0
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.