{ "info": { "author": "Jivan Amara", "author_email": "Development@JivanAmara.net", "bugtrack_url": null, "classifiers": [], "description": "This python module was written to help create database fixtures from an existing\ndatabase that is too large to simply dump it in its entirety.\nThanks to Jacob Rigby, Technical lead at Reya Group (http://www.reya.com)\nfor his unhesitating agreement to release this to the open source community.\n\nThe process copies the desired model instances to a separate database\nalong with their dependencies, and optionally children (instances dependent on\nthem). You can then dump the other database to get a minimal fixture\nfor your test case.\n\nQuick Reference:\ndef db_sample(\n\tdb_obj_iterable,\t# Iterable containing Django model instances\n\tchild_depth=1, \t\t# Set this to 2+ to also include children of children\n\tdb_alias='fixture_maker' # If you really need to use a different alias you can.\n)\n\nFirst use:\n 1. Add a database 'fixture_maker' to your settings file pointing to a\n database with a different name from your default database. Add\n \"'TEST_MIRROR': 'default'\" to the fixture_maker database settings\n to prevent the new database from being created during tests.\n \n 2. Create the database pointed to by alias fixture_maker (This step can be skipped\n if you're using sqlite, as it will automatically create the database when\n sync'd)\n\n 3. Run 'python manage.py syncdb --database=fixture_maker'.\n \t*note I've run into some trouble with South, syncdb, and the --database\n \t\tflag. If you're using south, you can work around this:\n \t\tMove your default database, do a 'syncdb --migrate' then rename\n \t\tthe resulting new default database as\n \t\tthe fixture maker database then move your original default database back.\n\n 4. Pass an iterable containing django model instances to db_sample().\n \tThis Example will save all the Pizza instances with olive topping to the\n \tfixture_maker database with their dependencies and by default children to\n \t1 level deep:\n\n \tfrom db_sampler_script import db_sample\n \t\n \tp = Pizza.objects.filter(toppings__type='olive')\n \tdb_sample(p)\n 5. Run 'python manage.py dumpdata --database=fixture_maker > your_new_fixture'\n \n Enjoy.\n\nSubsequent use:\n Skip steps 1 & 2, and replace step 3 with:\n 'python manage.py flush --database=fixture_maker'\n Be careful not to run this command without the --database flag, lest\n you erase your entire default database.\n\nAssumptions:\n Primary key for models is obj.id, if you've changed this for some models,\n \tplease let me know how it blows up.\n Foreign keys don't form loops (an object reference an object which eventually\n references the first). This is very rarely needed, and many databases\n make it difficult, so if you're not sure don't worry about it.\n If you have some loops like these and genuinely need them, let me know &\n I'll update the code to deal with it.\n Foreign keys that aren't NULL are assumed to be required for database\n consistency. At worst this will add some model instances to the resulting\n fixture that aren't really needed. Unless someone contacts me about\n this causing a real problem, it will likely stay like this.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JivanAmara/django_db_sampler", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django_db_sampler", "package_url": "https://pypi.org/project/django_db_sampler/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django_db_sampler/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/JivanAmara/django_db_sampler" }, "release_url": "https://pypi.org/project/django_db_sampler/0.21/", "requires_dist": null, "requires_python": null, "summary": "Utility to easily extract specific models from a database with their dependencies. Especially useful for creating fixtures.", "version": "0.21" }, "last_serial": 791086, "releases": { "0.2": [], "0.21": [ { "comment_text": "", "digests": { "md5": "90b98cabb889931a7027169b9461621a", "sha256": "6f514bad5cb7ba571936b1ae85c86fece177968a4ddab53f0b99b28dd72fb069" }, "downloads": -1, "filename": "django_db_sampler-0.21.tar.gz", "has_sig": false, "md5_digest": "90b98cabb889931a7027169b9461621a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4370, "upload_time": "2012-06-15T08:28:06", "url": "https://files.pythonhosted.org/packages/cc/65/8b77125c8c605410e8a48d51f26c5a254ba4d4198cca9303f5cd6dbcb457/django_db_sampler-0.21.tar.gz" }, { "comment_text": "", "digests": { "md5": "5180a332552b9832f3c359c1772b17f3", "sha256": "80e84ede37b4f83f3972bb8f3b3d410ff3a52bc474f7a1e00468eb04aa0b2688" }, "downloads": -1, "filename": "django_db_sampler-0.21.zip", "has_sig": false, "md5_digest": "5180a332552b9832f3c359c1772b17f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5438, "upload_time": "2012-06-15T08:28:24", "url": "https://files.pythonhosted.org/packages/a7/b5/ea8342856e8319e871aee4fc5639d7b672c6cb275c59e25abff6b676d48e/django_db_sampler-0.21.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "90b98cabb889931a7027169b9461621a", "sha256": "6f514bad5cb7ba571936b1ae85c86fece177968a4ddab53f0b99b28dd72fb069" }, "downloads": -1, "filename": "django_db_sampler-0.21.tar.gz", "has_sig": false, "md5_digest": "90b98cabb889931a7027169b9461621a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4370, "upload_time": "2012-06-15T08:28:06", "url": "https://files.pythonhosted.org/packages/cc/65/8b77125c8c605410e8a48d51f26c5a254ba4d4198cca9303f5cd6dbcb457/django_db_sampler-0.21.tar.gz" }, { "comment_text": "", "digests": { "md5": "5180a332552b9832f3c359c1772b17f3", "sha256": "80e84ede37b4f83f3972bb8f3b3d410ff3a52bc474f7a1e00468eb04aa0b2688" }, "downloads": -1, "filename": "django_db_sampler-0.21.zip", "has_sig": false, "md5_digest": "5180a332552b9832f3c359c1772b17f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5438, "upload_time": "2012-06-15T08:28:24", "url": "https://files.pythonhosted.org/packages/a7/b5/ea8342856e8319e871aee4fc5639d7b672c6cb275c59e25abff6b676d48e/django_db_sampler-0.21.zip" } ] }