djangosnippets.org: Latest snippets tagged with 'dump'http://djangosnippets.org/tags/dump/2013-01-03T09:33:54.695350-06:00MongoDB data dump
2013-01-03T09:33:54.695350-06:00jose_lpahttp://djangosnippets.org/snippets/2872/<p>This Django management command just dumps data from a given MongoDB collection into a JSON file.</p>
<p>To get it working, just create a <code>MONGODB_NAME</code> variable in settings, holding the name of your Mongo database. This can be edited to fit more your needs. The snippet requires Pymongo, since it uses …</p>
Freely redistributableDump a model instance and related objects as a Python data structure
2012-01-31T02:21:00.360253-06:00akaiholahttp://djangosnippets.org/snippets/2670/<p>This utility makes a text dump of a model instance, including objects related by a forward or reverse foreign key. The result is a hierarchical data structure where</p>
<ul>
<li>
<p>each instance is represented as a list of fields,</p>
</li>
<li>
<p>each field as a (<name>, <value>) tuple,</p>
</li>
<li>
<p>each <value> as a primitive type, …</p></li></ul>
Freely redistributabledjango_bulk_save.py - defer saving of django models to bulk SQL commits
2010-02-08T02:52:07.731305-06:00preetkukretihttp://djangosnippets.org/snippets/1913/<p>When called, this module dynamically alters the behaviour of model.save() on a list of models so that the SQL is returned and aggregated for a bulk commit later on. This is much faster than performing bulk writing operations using the standard model.save().</p>
<p>To use, simply save the code as django_bulk_save.py …</p>
Freely redistributableExport Models
2008-06-27T03:41:44.470215-05:00brunobordhttp://djangosnippets.org/snippets/825/<p>Warning: This python script is designed for Django 0.96.</p>
<p>It exports data from models quite like the <code>dumpdata</code> command, and throws the
data to the standard output.</p>
<p>It fixes glitches with unicode/ascii characters. It looked like the 0.96
handles very badly unicode characters, unless you specify an argument that is …</p>
Freely redistributableCommand to dump data as a python script
2008-06-20T12:26:34.864746-05:00willhardyhttp://djangosnippets.org/snippets/818/<p>This creates a fixture in the form of a python script.</p>
<p>Handles:</p>
<ol>
<li><code>ForeignKey</code> and <code>ManyToManyField</code>s (using python variables, not IDs)</li>
<li>Self-referencing <code>ForeignKey</code> (and M2M) fields</li>
<li>Sub-classed models</li>
<li><code>ContentType</code> fields</li>
<li>Recursive references</li>
<li><code>AutoField</code>s are excluded</li>
<li>Parent models are only included when no other child model links to it</li>
</ol>
<p>There …</p>
Freely redistributableVariable inspect filter
2008-05-06T17:22:57.602613-05:00buriyhttp://djangosnippets.org/snippets/743/<p>This module has two template filters allowing you to dump any template variable. Special handling for object instances. Pretty output.
</p>
<p>Usage:
{% load dumper %}
...
<pre>{{ var|rawdump }}</pre>
or
{% load dumper %}
...
{{ var2|dump }}
</p>
<p>How to install:
As usual, put into <code><your-proj>/<any-app>/templatetags/dumper.py</code>.
</p>
Freely redistributableDatabase migration and dump/load script
2007-04-10T13:56:38.196937-05:00akaiholahttp://djangosnippets.org/snippets/167/<p>I once needed to convert a Django project from PostgreSQL to SQLite. At that time I was either unaware of manage.py dumpdata/loaddata or it they didn't yet exist. I asked for advice on the #django IRC channel where ubernostrum came up with this plan:
</p>
<pre><code>simple process:
1) Select everything.
2) …</code></pre>
Freely redistributabledb_dump.py - for dumpping and loading data from database
2007-02-25T19:25:38.509691-06:00limodouhttp://djangosnippets.org/snippets/14/<h1>Description</h1>
<p>This tool is used for dump and restore database of Django. And it can also support some simple situations for Model changes, so it can also be used in importing data after the migration of Model.</p>
<p>It includes: dump and restore.</p>
<h1>Dump</h1>
<p>Command Line:</p>
<pre><code>python db_dump.py [-svdh] [--settings] dump …</code></pre>
Freely redistributable