Skip to content

Commit

Permalink
important fix! Check if engine is SQLite when setting PRAGMA's.
Browse files Browse the repository at this point in the history
Otherwise MYSQL support was broken !
  • Loading branch information
proost committed May 15, 2017
1 parent 0cf9abc commit 703c6a6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions planet/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit 703c6a6

Please sign in to comment.