0

I'm new to django and I wonder if there is anyway to use initial data without reinstalling custom sql each time. My initial data is almost 100MB and it's kind of painful to wait for database import for each test. I'm trying to find a way to do it without truncating my initial data.

eneepo
  • 1,407
  • 3
  • 21
  • 32

2 Answers2

1

Why don't you cache your data? You can either do that in process as a global variable. Depending on how you are running your server - multithreaded, multiprocessed, both - WSGI/Embedded - this may be easy or hard.

Another option is to use memcached.

Django caching is described here

  1. https://docs.djangoproject.com/en/dev/topics/cache/
  2. http://www.jeffknupp.com/blog/2012/02/24/django-memcached-optimizing-django-through-caching/

It's very easy to use it. The interface is simply a get(key) and set(key,value). You can use various kinds of caches:

  1. Filesystem (you should probably use this with multiple processes)
  2. In memory (for single process and single thread try this - will be faster)
Sid
  • 7,511
  • 2
  • 28
  • 41
  • As I said I'm a newbie and what you said is kind of challenging, I'd really appreciate if you recommend some helpful articles. I haven't read django doccmentaion on chaching is it enough to establish what you said? – eneepo Jun 25 '13 at 15:52
1

You might be looking for UnitTesting without create/destroy database

karthikr
  • 97,368
  • 26
  • 197
  • 188