Best way to (re)load test data in Mongo DB

Martin Sand Christensen martin.sand.christensen at gmail.com
Mon Feb 25 15:34:37 EST 2019


Nagy László Zsolt <gandalf at shopzeus.com> writes:

> We have a system where we have to create an exact copy of the original
> database for testing. The database size is over 800GB. [...]

That all sounds pretty cool, but it's precisely the opposite of what I'm
trying to acheive: keeping things as simple as possible. Snapshotting is
neat for testing, especially for the type of snapshots that writes
deltas on top of some base. ZopeDB offers precisely this sort of
feature directly, I've read; that's what I'd wish from every database.

> For much smaller databases, you can (of course) use pure python code to
> insert test data into a test database. If it only takes seconds, then it
> is not a problem, right? I believe that for small tests (e.g. unit
> tests), using python code to populate a test database is just fine.

Yeah... I'd just hoped to push it further down given that I only have
about a handful entries for each collection.

> Regarding question #2, you can always directly give an _id for documents
> if you want:
>
> https://api.mongodb.com/python/current/api/bson/objectid.html#bson.objectid.ObjectId

Cheers. I'll give it another go.


Martin



More information about the Python-list mailing list