|
@@ -1,17 +1,18 @@
|
|
import json
|
|
import json
|
|
-import sys
|
|
|
|
import os
|
|
import os
|
|
|
|
+import sys
|
|
# pylint: disable=wrong-import-position,wrong-import-order
|
|
# pylint: disable=wrong-import-position,wrong-import-order
|
|
import eventlet.tpool
|
|
import eventlet.tpool
|
|
eventlet.tpool.set_num_threads(2)
|
|
eventlet.tpool.set_num_threads(2)
|
|
|
|
|
|
-from pathlib import Path
|
|
|
|
from munch import munchify
|
|
from munch import munchify
|
|
|
|
+from pathlib import Path
|
|
|
|
|
|
from flask import Flask
|
|
from flask import Flask
|
|
from flask_migrate import Migrate
|
|
from flask_migrate import Migrate
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from sqlalchemy import event
|
|
from sqlalchemy import event
|
|
|
|
+from sqlalchemy import pool
|
|
from sqlalchemy.engine import Engine
|
|
from sqlalchemy.engine import Engine
|
|
|
|
|
|
print('- Loading settings')
|
|
print('- Loading settings')
|
|
@@ -23,14 +24,9 @@ with open('settings.json') as file:
|
|
if not os.path.exists(settings.projects_folder):
|
|
if not os.path.exists(settings.projects_folder):
|
|
os.mkdir(settings.projects_folder)
|
|
os.mkdir(settings.projects_folder)
|
|
|
|
|
|
-app = Flask(__name__)
|
|
|
|
-
|
|
|
|
-if "unittest" in sys.modules:
|
|
|
|
- # creates an in-memory DB
|
|
|
|
- DB_FILE = ""
|
|
|
|
-else:
|
|
|
|
- DB_FILE = Path.cwd() / settings.database
|
|
|
|
|
|
+DB_FILE = Path.cwd() / settings.database
|
|
|
|
|
|
|
|
+app = Flask(__name__)
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{DB_FILE}"
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{DB_FILE}"
|
|
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
|
|
|
|
@@ -42,5 +38,11 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
|
|
cursor.execute("PRAGMA foreign_keys=ON")
|
|
cursor.execute("PRAGMA foreign_keys=ON")
|
|
cursor.close()
|
|
cursor.close()
|
|
|
|
|
|
-db = SQLAlchemy(app)
|
|
|
|
|
|
+db = SQLAlchemy(app, engine_options=dict(
|
|
|
|
+ poolclass=pool.SingletonThreadPool,
|
|
|
|
+ connect_args=dict(
|
|
|
|
+ check_same_thread=False
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+)
|
|
migrate = Migrate(app, db)
|
|
migrate = Migrate(app, db)
|