From 703c6a6b8a6e4e24bbbc54c7a2eaa4c96834c42f Mon Sep 17 00:00:00 2001 From: sepro Date: Mon, 15 May 2017 11:41:50 +0200 Subject: [PATCH] important fix! Check if engine is SQLite when setting PRAGMA's. Otherwise MYSQL support was broken ! --- planet/extensions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/planet/extensions.py b/planet/extensions.py index c155d5e..552893c 100644 --- a/planet/extensions.py +++ b/planet/extensions.py @@ -8,6 +8,7 @@ from sqlalchemy.engine import Engine from sqlalchemy import event +from sqlite3 import Connection as SQLite3Connection from planet.flask_blast import BlastThread @@ -21,9 +22,10 @@ def set_sqlite_pragma(dbapi_connection, connection_record): """ Will force sqlite contraint foreign keys """ - cursor = dbapi_connection.cursor() - cursor.execute("PRAGMA foreign_keys=ON") - cursor.close() + if isinstance(dbapi_connection, SQLite3Connection): + cursor = dbapi_connection.cursor() + cursor.execute("PRAGMA foreign_keys=ON") + cursor.close() login_manager = LoginManager() toolbar = DebugToolbarExtension()