From f326bf9148bfb9447abbdc9f2e42771125288865 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 13 May 2020 21:25:17 +0100 Subject: [PATCH] more thorough reset between dbs --- databaseReset.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/databaseReset.py b/databaseReset.py index 455de8d..04b8f98 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -252,10 +252,12 @@ class JobQueue(): dbengine = settings.DATABASES['default']['ENGINE'] dbname = settings.DATABASES['default']['NAME'] + dbdefault = settings.DATABASES['default'] if dbname ==":memory:": # just run, and save the sql file print "-- ", settings.DATABASES['default']['NAME'], settings.DATABASES['default']['ENGINE'] + print "-- DATABASES.default", settings.DATABASES['default'] self.runqonce() self.memdumpsql() self.saveprofiles() @@ -263,7 +265,11 @@ class JobQueue(): # run all the imports through :memory: first settings.DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' settings.DATABASES['default']['NAME'] = ":memory:" + settings.DATABASES['default']['USER'] = "" + settings.DATABASES['default']['PASSWORD'] = "" + print "-- ", settings.DATABASES['default']['NAME'], settings.DATABASES['default']['ENGINE'] + print "-- DATABASES.default", settings.DATABASES['default'] # but because the user may be expecting to add this to a db with lots of tables already there, # the jobque may not start from scratch so we need to initialise the db properly first @@ -287,6 +293,7 @@ class JobQueue(): # restore the original db and import again # if we wanted to, we could re-import the SQL generated in the first pass to be # blazing fast. But for the present just re-import the lot. + settings.DATABASES['default'] = dbdefault settings.DATABASES['default']['ENGINE'] = dbengine settings.DATABASES['default']['NAME'] = dbname print "-- ", settings.DATABASES['default']['NAME'], settings.DATABASES['default']['ENGINE']