From 37d2a5561724b850c804fd1bcb7d00ae9a6e67a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=A9fir=20Destiny?= Date: Sun, 15 Dec 2019 12:42:46 +0100 Subject: [PATCH] Fix pymysql --- config.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index 1496ac1..71a4adf 100644 --- a/config.py +++ b/config.py @@ -1,16 +1,12 @@ from os import environ, urandom -from sys import modules -import pymysql from flask import Flask from flask.cli import load_dotenv from flask_httpauth import HTTPBasicAuth from flask_sqlalchemy import SQLAlchemy -modules["MySQLdb"] = pymysql -load_dotenv() - # init DB and migration +load_dotenv() db_user = environ.get('MYSQL_USER') db_password = environ.get('MYSQL_PASSWORD') db_name = environ.get('MYSQL_DATABASE') @@ -27,7 +23,9 @@ APP_PORT = environ.get('FLASK_PORT', 5000) app = Flask(__name__) app.secret_key = urandom(24).hex() -app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://%s:%s@%s/%s?charset=utf8mb4' % (db_user, db_password, db_host, db_name) +app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://%s:%s@%s/%s?charset=utf8mb4' % ( + db_user, db_password, db_host, db_name +) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True app.config['SQLALCHEMY_ECHO'] = IS_DEBUG auth = HTTPBasicAuth()