Not reliable.
The proper way to do this is to use init_command in the db parameters OPTIONS dictionary:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', ... 'OPTIONS': { 'init_command': '"SET SESSION wait_timeout=2147483', }, } }
source share