force mysql to use utf8mb4 for connections, related to #117

This commit is contained in:
meeb 2021-05-17 01:27:50 +10:00
parent d4fd148089
commit 0db8db4351
1 changed files with 7 additions and 0 deletions

View File

@ -18,6 +18,12 @@ def parse_database_connection_string(database_connection_string):
'postgresql': 'django.db.backends.postgresql',
'mysql': 'django.db.backends.mysql',
}
backend_options = {
'postgresql': {},
'mysql': {
'charset': 'utf8mb4',
}
}
try:
parts = urlparse(str(database_connection_string))
except Exception as e:
@ -80,6 +86,7 @@ def parse_database_connection_string(database_connection_string):
'HOST': hostname,
'PORT': port,
'CONN_MAX_AGE': 300,
'OPTIONS': backend_options.get(driver),
}