Hi On Thu, 08 Jun 2006 23:07:51 -0400, Todd O'Bryan wrote:
> And then I need to be running under program control again to add all > my test data to the the db. > > Please tell me that I'm overthinking this and there's some easy way > out of this! The other posters in this thread do give nice solutions. I just extracted the minimum needed to create a testing DB in memory using sqlite. This is what I have: ----- cut here ----- import os os.environ['DJANGO_SETTINGS_MODULE']='MYSITE.settings' def createdb(): from django import db from django.conf import settings settings.DATABASE_ENGINE = "sqlite3" settings.DATABASE_NAME = ":memory:" reload(db) from django.core.management import syncdb from django.dispatch import dispatcher from django.dispatch.errors import DispatcherKeyError from django.contrib.auth.management import create_superuser from django.contrib.auth import models as auth_app from django.db.models import signals db.connection.close() # disable the "create a super user" question try: dispatcher.disconnect(create_superuser, sender=auth_app, signal=signals.post_syncdb) except DispatcherKeyError: # This must be run only once per session pass syncdb() ----- cut here ----- This presumes that MYSITE is in sys.path. I find that using nosetest (http://somethingaboutorange.com/mrl/projects/nose/) from the directory below MYSITE works pretty well, since it takes care of sys.path. Another comment: The placement of from django import db, and reload(db) seems to be critical. The django.db module needs to be imported before django.settings, and has to be reloaded after changing settings.DATABASE_ENGINE. If you were already using sqlite I guess that's not a problem. > > Thanks, -- you know its kind of tragic we live in the new world but we've lost the magic -- Battery 9 (www.battery9.co.za) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---