Skip to content

Commit

Permalink
Changed SQLite to utilize WAL mode instead of journaling (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Security-Chief-Odo authored Sep 19, 2023
1 parent 9b0c669 commit b3441d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fedi_safety_api/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from werkzeug.middleware.proxy_fix import ProxyFix
from flask_sqlalchemy import SQLAlchemy
from loguru import logger
from sqlalchemy import event
from sqlalchemy.engine import Engine

os.makedirs(os.getenv("FEDIVERSE_SAFETY_IMGDIR"), exist_ok=True)
cache = None
Expand Down Expand Up @@ -46,3 +48,9 @@
cache.init_app(APP)
logger.init_warn("Flask Cache", status="SimpleCache")

@event.listens_for(Engine, "connect")
def set_sqlite_pragma(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA journal_mode=WAL;")
cursor.close()
logger.info("Set pragma to wal")

0 comments on commit b3441d4

Please sign in to comment.