Skip to content

Commit

Permalink
Removed MariaDB/MySQL Support (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivangi-ch authored Mar 18, 2024
1 parent 5ba97c9 commit 3c0c683
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 39 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM python:3.8
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
default-libmysqlclient-dev \
gettext \
git \
libffi-dev \
Expand Down Expand Up @@ -51,7 +50,6 @@ RUN pip3 install -U \
pip3 install \
-r requirements.txt \
-r requirements/memcached.txt \
-r requirements/mysql.txt \
gunicorn django-extensions ipython && \
rm -rf ~/.cache/pip

Expand Down
11 changes: 2 additions & 9 deletions doc/admin/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,23 @@ Database settings
Example::

[database]
backend=mysql
backend=postgresql
name=pretix
user=pretix
password=abcd
host=localhost
port=3306

``backend``
One of ``mysql``, ``sqlite3``, ``oracle`` and ``postgresql``.
One of ``sqlite3``, ``oracle`` and ``postgresql``.
Default: ``sqlite3``.

If you use MySQL, be sure to create your database using
``CREATE DATABASE <dbname> CHARACTER SET utf8;``. Otherwise, Unicode
support will not properly work.

``name``
The database's name. Default: ``db.sqlite3``.

``user``, ``password``, ``host``, ``port``
Connection details for the database connection. Empty by default.

``galera``
Indicates if the database backend is a MySQL/MariaDB Galera cluster and
turns on some optimizations/special case handlers. Default: ``False``

.. _`config-replica`:

Expand Down
25 changes: 7 additions & 18 deletions src/pretix/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import urlparse
from .settings_helpers import build_db_tls_config, build_redis_tls_config
import django.conf.locale
from django.core.exceptions import ImproperlyConfigured
from django.utils.crypto import get_random_string
from kombu import Queue
from pkg_resources import iter_entry_points
Expand Down Expand Up @@ -71,17 +72,11 @@
db_backend = config.get('database', 'backend', fallback='sqlite3')
if db_backend == 'postgresql_psycopg2':
db_backend = 'postgresql'
DATABASE_IS_GALERA = config.getboolean('database', 'galera', fallback=False)
if DATABASE_IS_GALERA and 'mysql' in db_backend:
db_options = {
'init_command': 'SET SESSION wsrep_sync_wait = 1;'
}
else:
db_options = {}
if db_backend == 'mysql':
raise ImproperlyConfigured("MySQL/MariaDB is not supported")

if 'mysql' in db_backend:
db_options['charset'] = 'utf8mb4'
JSON_FIELD_AVAILABLE = db_backend in ('mysql', 'postgresql')
JSON_FIELD_AVAILABLE = db_backend == 'postgresql'
db_options = {}

db_tls_config = build_db_tls_config(config, db_backend)
if (db_tls_config is not None):
Expand All @@ -98,10 +93,7 @@
'PORT': config.get('database', 'port', fallback=''),
'CONN_MAX_AGE': 0 if db_backend == 'sqlite3' else 120,
'OPTIONS': db_options,
'TEST': {
'CHARSET': 'utf8mb4',
'COLLATION': 'utf8mb4_unicode_ci',
} if 'mysql' in db_backend else {}
'TEST': {}
}
}
DATABASE_REPLICA = 'default'
Expand All @@ -116,10 +108,7 @@
'PORT': config.get('replica', 'port', fallback=DATABASES['default']['PORT']),
'CONN_MAX_AGE': 0 if db_backend == 'sqlite3' else 120,
'OPTIONS': db_options,
'TEST': {
'CHARSET': 'utf8mb4',
'COLLATION': 'utf8mb4_unicode_ci',
} if 'mysql' in db_backend else {}
'TEST': {}
}
DATABASE_ROUTERS = ['pretix.helpers.database.ReplicaRouter']

Expand Down
2 changes: 0 additions & 2 deletions src/requirements/mysql.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def run(self):
'freezegun',
],
'memcached': ['pylibmc'],
'mysql': ['mysqlclient'],
},

packages=find_packages(exclude=['tests', 'tests.*']),
Expand Down
7 changes: 0 additions & 7 deletions src/tests/travis_mysql.cfg

This file was deleted.

0 comments on commit 3c0c683

Please sign in to comment.