From 02ce0dc02ef85db0485af262f81bce768c89091a Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 22 Feb 2022 19:31:58 +0100 Subject: [PATCH] Set journal mode to wal for sqlite databases closes #6353 --- freqtrade/persistence/migrations.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/freqtrade/persistence/migrations.py b/freqtrade/persistence/migrations.py index 60c0eb5f9..5817c5a97 100644 --- a/freqtrade/persistence/migrations.py +++ b/freqtrade/persistence/migrations.py @@ -186,6 +186,13 @@ def migrate_orders_table(engine, table_back_name: str, cols: List): """)) +def set_sqlite_to_wal(engine): + if engine.name == 'sqlite' and str(engine.url) != 'sqlite://': + # Set Mode to + with engine.begin() as connection: + connection.execute(text("PRAGMA journal_mode=wal")) + + def check_migrate(engine, decl_base, previous_tables) -> None: """ Checks if migration is necessary and migrates if necessary @@ -212,3 +219,4 @@ def check_migrate(engine, decl_base, previous_tables) -> None: if 'orders' not in previous_tables and 'trades' in previous_tables: logger.info('Moving open orders to Orders table.') migrate_open_orders_to_trades(engine) + set_sqlite_to_wal(engine)