Verified Commit 255b9d58 authored by Grégor JOUET's avatar Grégor JOUET 🔧
Browse files

[DB] Use Connection Mixin

parent 602233ee
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -13,9 +13,13 @@ from peewee import (
import datetime
import sys, os
import myfab.log as log
import playhouse.shortcuts.ReconnectMixin

CONNECTION = None

class ReconnectMySQLDatabase(ReconnectMixin, MySQLDatabase):
    pass


def create_mysql_connection() -> MySQLDatabase:
    global CONNECTION
@@ -30,7 +34,7 @@ def create_mysql_connection() -> MySQLDatabase:

    url = os.environ["MYSQL_HOST"]
    log.info("Using MYSQL_HOST %s" % url)
    return MySQLDatabase(
    return ReconnectMySQLDatabase(
        os.environ["MYSQL_DB"],
        user=os.environ["MYSQL_USER"],
        host=url,
+2 −1
Original line number Diff line number Diff line
@@ -5,3 +5,4 @@ flask_jwt_extended
flask-cors
flask_api
requests
playhouse
 No newline at end of file