From 177181d1c0af0799ef036f43a5802fb677a877d0 Mon Sep 17 00:00:00 2001 From: mowoe <github@mowoe.com> Date: Sun, 28 Apr 2019 10:46:19 +0200 Subject: [PATCH] mysql support --- dockercont/Dockerfile | 1 + model/__init__.py | 11 +++++++++-- model/sample_creds.json | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 model/sample_creds.json diff --git a/dockercont/Dockerfile b/dockercont/Dockerfile index 944e91d..933af0a 100644 --- a/dockercont/Dockerfile +++ b/dockercont/Dockerfile @@ -1,4 +1,5 @@ FROM tiangolo/uwsgi-nginx-flask:python3.6 RUN pip install peewee +RUN pip install mysql RUN git clone https://gitlab.warpzone.ms/mowoe/chaos_familien_duell_frontend.git /zwisch RUN mv /zwisch/* /app diff --git a/model/__init__.py b/model/__init__.py index 230d3c2..2a7452b 100644 --- a/model/__init__.py +++ b/model/__init__.py @@ -1,8 +1,15 @@ from peewee import SqliteDatabase from peewee import Model +from peewee import MySQLDatabase +import json + +mysql_creds = json.load(open("./creds.json")) + +#sqlite = SqliteDatabase("model/cfd.sqlite", pragmas={'foreign_keys': 1}) +#sqlite.connect() +sqlite = MySQLDatabase(mysql_creds["db"], user=mysql_creds["user"], password=mysql_creds['password'], + host=mysql_creds['host'], port=int(mysql_creds['port']),) -sqlite = SqliteDatabase("model/cfd.sqlite", pragmas={'foreign_keys': 1}) -sqlite.connect() class BaseModel(Model): diff --git a/model/sample_creds.json b/model/sample_creds.json new file mode 100644 index 0000000..04f6260 --- /dev/null +++ b/model/sample_creds.json @@ -0,0 +1,3 @@ +{ + "host":"","user":"","password":"","db":"","port":1337 +} \ No newline at end of file -- GitLab