From da493d07c01eadcdc973054d53390a3daa574ff9 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 22 Mar 2017 20:38:23 -0700 Subject: [PATCH] recreate DB connection (cherry picked from commit 5593e28) --- _development/helpers.py | 14 ++++++++++++++ eos/db/__init__.py | 2 -- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/_development/helpers.py b/_development/helpers.py index 1cfad6b9a..89adade8b 100644 --- a/_development/helpers.py +++ b/_development/helpers.py @@ -4,6 +4,9 @@ import pytest import os import sys +from sqlalchemy import MetaData, create_engine +from sqlalchemy.orm import sessionmaker + script_dir = os.path.dirname(os.path.abspath(__file__)) # Add root folder to python paths sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..'))) @@ -27,6 +30,17 @@ def DBInMemory(): import eos import eos.db + # Replace the existing DB connection with our own. For some reason on Linux, it ignores what we set above. :( + if callable('sqlite:///:memory:'): + eos.db.saveddata_engine = create_engine(creator='sqlite:///:memory:', echo=eos.config.debug) + else: + eos.db.saveddata_engine = create_engine('sqlite:///:memory:', echo=eos.config.debug) + + eos.db.saveddata_meta = MetaData() + eos.db.saveddata_meta.bind = eos.db.saveddata_engine + eos.db.saveddata_session = sessionmaker(bind=eos.db.saveddata_engine, autoflush=False, expire_on_commit=False)() + eos.db.saveddata_meta.create_all() + # Output debug info to help us troubleshoot Travis print(eos.db.saveddata_engine) print(eos.db.gamedata_engine) diff --git a/eos/db/__init__.py b/eos/db/__init__.py index 3014d7274..680c67e1e 100644 --- a/eos/db/__init__.py +++ b/eos/db/__init__.py @@ -54,8 +54,6 @@ except Exception as e: pyfalog.critical(e) config.gamedata_version = None -print("Test: " + config.saveddata_connectionstring) - saveddata_connectionstring = config.saveddata_connectionstring if saveddata_connectionstring is not None: if callable(saveddata_connectionstring):