persistence: adapt checks to detect in-memory db
This commit is contained in:
parent
01675f50bf
commit
ac602ed5a9
@ -16,8 +16,6 @@ from sqlalchemy.orm.scoping import scoped_session
|
|||||||
from sqlalchemy.orm.session import sessionmaker
|
from sqlalchemy.orm.session import sessionmaker
|
||||||
from sqlalchemy.pool import StaticPool
|
from sqlalchemy.pool import StaticPool
|
||||||
|
|
||||||
from freqtrade import constants
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
_CONF = {}
|
_CONF = {}
|
||||||
@ -37,8 +35,8 @@ def init(config: Dict) -> None:
|
|||||||
db_url = _CONF.get('db_url', None)
|
db_url = _CONF.get('db_url', None)
|
||||||
kwargs = {}
|
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({
|
kwargs.update({
|
||||||
'connect_args': {'check_same_thread': False},
|
'connect_args': {'check_same_thread': False},
|
||||||
'poolclass': StaticPool,
|
'poolclass': StaticPool,
|
||||||
@ -52,8 +50,8 @@ def init(config: Dict) -> None:
|
|||||||
_DECL_BASE.metadata.create_all(engine)
|
_DECL_BASE.metadata.create_all(engine)
|
||||||
check_migrate(engine)
|
check_migrate(engine)
|
||||||
|
|
||||||
# Clean dry_run DB
|
# Clean dry_run DB if the db is not in-memory
|
||||||
if _CONF.get('dry_run', False) and db_url != constants.DEFAULT_DB_DRYRUN_URL:
|
if _CONF.get('dry_run', False) and db_url != 'sqlite://':
|
||||||
clean_dry_run_db()
|
clean_dry_run_db()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user