def _create_main_db(): """Returns a dbreader instance, that is connected to the main game data dbfiles. NOTE: This data is read_only, so there are no concurrency issues""" _db = UhDbAccessor(':memory:') for i in PATHS.DB_FILES: f = open(i, "r") sql = "BEGIN TRANSACTION;" + f.read() + "COMMIT;" _db.execute_script(sql) return _db
def _create_main_db(): """Returns a dbreader instance, that is connected to the main game data dbfiles. NOTE: This data is read_only, so there are no concurrency issues.""" _db = UhDbAccessor(':memory:') for i in PATHS.DB_FILES: with open(i, "r") as f: sql = "BEGIN TRANSACTION;" + f.read() + "COMMIT;" _db.execute_script(sql) return _db
def setup_package(): """ One-time database setup. Nose will call this function once for this package, so we can avoid to create a database for each test. Using TestCase, we can be sure that each test runs on an unmodified database. """ global db, temp_dir db = UhDbAccessor(":memory:") for i in PATHS.DB_FILES: db.execute_script(open(i, "r").read()) # Truncate all tables. We don't want to rely on existing data. for (table_name,) in db("SELECT name FROM sqlite_master WHERE type = 'table'"): db("DELETE FROM %s" % table_name)
def _create_db(): """Returns a dbreader instance, that is connected to the main game data dbfiles. NOTE: This data is read_only, so there are no concurrency issues""" _db = UhDbAccessor(':memory:') _db("ATTACH ? AS data", 'content/game.sqlite') _db("ATTACH ? AS settler", 'content/settler.sqlite') _db("ATTACH ? AS balance", 'content/balance.sqlite') return _db