From ac602ed5a9e919d38e066108e87c563fb71a34f6 Mon Sep 17 00:00:00 2001 From: gcarq Date: Thu, 7 Jun 2018 19:10:26 +0200 Subject: [PATCH] persistence: adapt checks to detect in-memory db --- freqtrade/persistence.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index aa8a978d5..ce834bced 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -16,8 +16,6 @@ from sqlalchemy.orm.scoping import scoped_session from sqlalchemy.orm.session import sessionmaker from sqlalchemy.pool import StaticPool -from freqtrade import constants - logger = logging.getLogger(__name__) _CONF = {} @@ -37,8 +35,8 @@ def init(config: Dict) -> None: db_url = _CONF.get('db_url', None) kwargs = {} - if db_url == constants.DEFAULT_DB_DRYRUN_URL: - # Take care of thread ownership if in-memory db + # Take care of thread ownership if in-memory db + if db_url == 'sqlite://': kwargs.update({ 'connect_args': {'check_same_thread': False}, 'poolclass': StaticPool, @@ -52,8 +50,8 @@ def init(config: Dict) -> None: _DECL_BASE.metadata.create_all(engine) check_migrate(engine) - # Clean dry_run DB - if _CONF.get('dry_run', False) and db_url != constants.DEFAULT_DB_DRYRUN_URL: + # Clean dry_run DB if the db is not in-memory + if _CONF.get('dry_run', False) and db_url != 'sqlite://': clean_dry_run_db()