I have this in my Django 4.2.11’s settings.py which uses MySQL 8.1
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['DATABASE_NAME'],
'USER': os.environ['DATABASE_USER'],
'PASSWORD': os.environ['DATABASE_PASS'],
'HOST': os.environ['DATABASE_HOST'],
'PORT': os.environ['DATABASE_PORT'],
},
'scout': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['SCOUT_DATABASE_NAME'],
'USER': os.environ['SCOUT_DATABASE_USER'],
'PASSWORD': os.environ['SCOUT_DATABASE_PASS'],
'HOST': os.environ['SCOUT_DATABASE_HOST'],
'PORT': os.environ['SCOUT_DATABASE_PORT'],
},
}
SCOUT_DATABASE_HOST
is a remote IP which is on MySQL 5.6
query = f"INSERT INTO table_name ( ... )"
This query works when executed on the remote server’s MySQL 5.6 command line.
But on our Django server, it fails and throws an error that the mysql 8 or above required , (found 5.6.31)
try:
cursor_scout = connections['scout'].cursor()
cursor_scout.execute(query)
return JsonResponse({'status': 'true'})
except Exception as e:
return JsonResponse({'status': 'false', 'error': str(e)})
So Django is not executing the SQL query because the Django app is using a driver for 8.x specifically and is not willing to execute a query for a 5.6 server ?
Is there an option to specify in settings to use 5.6 driver for scout ?