Hi, I'm a newbie with Django, and I'm having trouble accessing django database outside the web server.
I'm using mod_python+apache+MySQL without any problem. However I need for my project to *also* access the database *outside* of mod_python. I wrote a script service.py which is supposed to access periodically the database, as a background service: > python service.py --service This service.py file looks like this (the code was borrowed from settings.py): >>>>>>>>>>>>>>>>>>>>> CUT from django.core.management import setup_environ try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file [...]) sys.exit(1) print setup_environ(settings) from djangoserver.myserver.models import Job, Dummy, ... # XXX: (Temporary) workaround for ticket #1796: force early loading of all # models from installed apps. from django.db.models.loading import get_models loaded_models = get_models() [...] <<<<<<<<<<<<<<<<<<<<< CUT The script service.py then looks for jobs to work on: >>>>>>>>>>>>>>>>>>>>> CUT while 1: hadJob = doOneRun() if not hadJob: time.sleep(0.100) # WORK AROUND: just to defeat the sql cache d = Dummy(foo="1") d.save() d.delete() <<<<<<<<<<<<<<<<<<<<< CUT As you might see, I run into the problem that the Job table was not getting re-fetched my MySQL. I found a work around by creating a Dummy model, and by forcing an update on the table (d.save()). Could someone point me to a way to do a background job with Django? Is there a cache I need to flush in order for Django to re-query the database? Many thanks! alex --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---