i want to create on function in which i can pass my connection details and connect to that database.
this is the current connection details which i am getting from
from django.db import connection
{'ENGINE': 'django.db.backends.mysql', 'NAME': 'S1', 'USER': 'wtc', 'PASSWORD': 'Black@97', 'HOST': 'localhost', 'PORT': 3306, 'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'OPTIONS': {}, 'TIME_ZONE': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}}
now let say i want to connect to database S2. but my below code is not working.
# Switch the database connection
print('called', connection.settings_dict)
connection.disconnect()
connection.settings_dict['NAME'] = 'scgtplatform'
print('connected')
it says AttributeError: ‘DatabaseWrapper’ object has no attribute ‘disconnect’