0

The connection URL to my MySQL server is like so

jdbc:mysql://server1:3306,server2:3306,server3:3306/mydb

After I parse and extract the hosts and ports, how can I pass it in Django DATABASES section below?

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'mydb',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'server1',
        'PORT': '3306'
    }
}
MajorXbox
  • 503
  • 1
  • 4
  • 13
  • Are these read replicas? If so you may need to handle load balancing to these outside of Django. If they are for different content see: https://docs.djangoproject.com/en/2.2/topics/db/multi-db/ – Theodore Howell May 02 '19 at 22:32
  • @TheodoreHowell, these are replicas. – MajorXbox May 02 '19 at 23:22
  • I believe that is out of the scope of the Django ORM, I would handle load balancing requests elsewhere in the stack unless it is not possible. – Theodore Howell May 03 '19 at 18:13

0 Answers0