def upgrade(saveddata_engine): from eos.db import saveddata_session from eos.db.saveddata.fit import commandFits_table sql = """ SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost FROM squadmembers sm JOIN squads s ON s.ID = sm.squadID JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({"boosterID": value, "boostedID": boosted, "active": 1}) try: saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1}) except Exception: pass saveddata_session.commit()
def upgrade(saveddata_engine): from eos.db import saveddata_session from eos.db.saveddata.fit import commandFits_table sql = """ SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost FROM squadmembers sm JOIN squads s ON s.ID = sm.squadID JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ try: results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({"boosterID": value, "boostedID": boosted, "active": 1}) try: saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1}) except Exception: pass saveddata_session.commit() except: # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version # If it does, simply fail. Fleet data migration isn't critically important here pass
def commit(): with sd_lock: try: saveddata_session.commit() except Exception: saveddata_session.rollback() exc_info = sys.exc_info() raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
def removeInvalid(fits): invalids = [f for f in fits if f.isInvalid] if invalids: map(fits.remove, invalids) map(saveddata_session.delete, invalids) saveddata_session.commit() return fits
def removeInvalid(fits): invalids = [f for f in fits if f.isInvalid] if invalids: list(map(fits.remove, invalids)) list(map(saveddata_session.delete, invalids)) saveddata_session.commit() return fits
def commit(): with sd_lock: try: saveddata_session.commit() saveddata_session.flush() except Exception: saveddata_session.rollback() exc_info = sys.exc_info() raise exc_info[0], exc_info[1], exc_info[2]
def commit(): with sd_lock: try: saveddata_session.commit() except (KeyboardInterrupt, SystemExit): raise except Exception: saveddata_session.rollback() exc_info = sys.exc_info() raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
def upgrade(saveddata_engine): from eos.db import saveddata_session sql = """ DELETE FROM commandFits WHERE boosterID NOT IN (select ID from fits) OR boostedID NOT IN (select ID from fits) """ saveddata_session.execute(sql) saveddata_session.commit()
def upgrade(saveddata_engine): from eos.db import saveddata_session from eos.db.saveddata.fit import commandFits_table sql = """ SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost FROM squadmembers sm JOIN squads s ON s.ID = sm.squadID JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ try: results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({ "boosterID": value, "boostedID": boosted, "active": 1 }) try: saveddata_session.execute(commandFits_table.insert(), { "boosterID": value, "boostedID": boosted, "active": 1 }) except (KeyboardInterrupt, SystemExit): raise except Exception: pass saveddata_session.commit() except (KeyboardInterrupt, SystemExit): raise except: # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version # If it does, simply fail. Fleet data migration isn't critically important here pass
def upgrade(saveddata_engine): from eos.db import saveddata_session from eos.db.saveddata.fit import commandFits_table sql = """ SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost FROM squadmembers sm JOIN squads s ON s.ID = sm.squadID JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({ "boosterID": value, "boostedID": boosted, "active": 1 }) try: saveddata_session.execute(commandFits_table.insert(), { "boosterID": value, "boostedID": boosted, "active": 1 }) except Exception: pass saveddata_session.commit()
def commit(): with sd_lock: saveddata_session.commit() saveddata_session.flush()
def upgrade(saveddata_engine): from eos.db import saveddata_session from eos.db.saveddata.fit import commandFits_table sql = """ SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost FROM squadmembers sm JOIN squads s ON s.ID = sm.squadID JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({"boosterID": value, "boostedID": boosted, "active": 1}) try: saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1}) except Exception, e: pass saveddata_session.commit()
JOIN wings w on w.ID = s.wingID JOIN gangs g on g.ID = w.gangID """ results = saveddata_session.execute(sql) inserts = [] for row in results: boosted = row["boostedFit"] types = ("squad", "wing", "gang") for x in types: value = row["{}Boost".format(x)] if value is None: continue inserts.append({ "boosterID": value, "boostedID": boosted, "active": 1 }) try: saveddata_session.execute(commandFits_table.insert(), { "boosterID": value, "boostedID": boosted, "active": 1 }) except Exception, e: pass saveddata_session.commit()