[db] Try mysqlclient first, maybe the user managed to get it working on Windows

This commit is contained in:
Ferdinand Thiessen 2021-05-27 01:52:30 +02:00
parent 7b5f854d51
commit 7928c16c07
1 changed files with 6 additions and 1 deletions

View File

@ -69,7 +69,12 @@ def configure_app(app, test_config=None):
config["DATABASE"]["engine"] = "sqlite"
if config["DATABASE"]["engine"] == "mysql":
engine = "mysql" + ("+pymysql" if os.name == "nt" else "")
engine = "mysql"
try:
# Try mysqlclient first
from MySQLdb import _mysql
except ModuleNotFoundError:
engine += "+pymysql"
options = "?charset=utf8mb4"
elif config["DATABASE"]["engine"] == "postgres":
engine = "postgresql+psycopg2"