2
votes

I am trying to write a script that reads a table and inserts into other using Django's orm'. the code can be found here: http://pastebin.com/CfUtqve6

problem is when i try to run on terminal i get this error

"django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details."

my settings is rightly configured as ./manage.py runserver makes no complaints. for clarity its like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'zingyhomes',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'root',                  # Not used with sqlite3.
        'HOST': '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

whats causing this trouble, how should i overcome it and write that script thats eluding me so far ;)

1

1 Answers

0
votes

Your problem is that you are not referencing your actual settings file in any way. You import the default Django settings, and then call settings.configure(): but of course they don't include your DATABASES setting.

As Iain points out in the comments, you should write this script as a custom management command, as that will take care of the settings stuff for you.