def execute(self, *args, **options): settings = connections['default'].settings_dict.copy() settings['ENGINE'] = 'sqlite3' if 'application_name' in settings['OPTIONS']: del settings['OPTIONS']['application_name'] connections['default'] = DatabaseWrapper(settings) return MakeMigrations().execute(*args, **options)
def test_memory_db_test_name(self): """A named in-memory db should be allowed where supported.""" from django.db.backends.sqlite3.base import DatabaseWrapper settings_dict = { 'TEST': { 'NAME': 'file:memorydb_test?mode=memory&cache=shared', } } creation = DatabaseWrapper(settings_dict).creation self.assertEqual(creation._get_test_db_name(), creation.connection.settings_dict['TEST']['NAME'])
def test_memory_db_test_name(self): """A named in-memory db should be allowed where supported.""" from django.db.backends.sqlite3.base import DatabaseWrapper settings_dict = { 'TEST': { 'NAME': 'file:memorydb_test?mode=memory&cache=shared', } } wrapper = DatabaseWrapper(settings_dict) creation = wrapper.creation if creation.connection.features.can_share_in_memory_db: expected = creation.connection.settings_dict['TEST']['NAME'] self.assertEqual(creation._get_test_db_name(), expected) else: msg = ("Using a shared memory database with `mode=memory` in the " "database name is not supported in your environment, " "use `:memory:` instead.") with self.assertRaisesMessage(ImproperlyConfigured, msg): creation._get_test_db_name()
def execute(self, *args, **options): settings = connections['default'].settings_dict.copy() settings['ENGINE'] = 'sqlite3' connections['default'] = DatabaseWrapper(settings) return MakeMigrations().execute(*args, **options)