change method for retreiving count
This commit is contained in:
@@ -40,7 +40,13 @@ class DatabaseCleanup:
|
||||
results = saveddata_engine.execute("SELECT COUNT(*) AS num FROM characterSkills "
|
||||
"WHERE characterID NOT IN (SELECT ID from characters)")
|
||||
|
||||
if results.fetchone()['num'] > 0:
|
||||
count_results = 0
|
||||
for result in results:
|
||||
count_results = result[0]
|
||||
break
|
||||
|
||||
# Count how many records exist. This is ugly, but SQLAlchemy doesn't return a count from a select query.
|
||||
if count_results > 0:
|
||||
delete = saveddata_engine.execute("DELETE FROM characterSkills WHERE characterID NOT IN (SELECT ID from characters)")
|
||||
logger.error("Database corruption found. Cleaning up %d records.", delete.rowcount)
|
||||
|
||||
@@ -56,7 +62,13 @@ class DatabaseCleanup:
|
||||
logger.debug("Running database cleanup for orphaned damage patterns attached to fits.")
|
||||
results = saveddata_engine.execute("SELECT COUNT(*) AS num FROM fits WHERE damagePatternID not in (select ID from damagePatterns)")
|
||||
|
||||
if results.fetchone()['num'] > 0:
|
||||
count_results = 0
|
||||
for result in results:
|
||||
count_results = result[0]
|
||||
break
|
||||
|
||||
# Count how many records exist. This is ugly, but SQLAlchemy doesn't return a count from a select query.
|
||||
if count_results > 0:
|
||||
# Get Uniform damage pattern ID
|
||||
uniform_results = saveddata_engine.execute("select ID from damagePatterns WHERE name = 'Uniform'")
|
||||
|
||||
@@ -80,13 +92,18 @@ class DatabaseCleanup:
|
||||
|
||||
@staticmethod
|
||||
def OrphanedFitCharacterIDs(saveddata_engine):
|
||||
# Find orphaned character IDs. This solves an issue where the chaaracter doesn't exist, but fits reference the pattern.
|
||||
# Find orphaned character IDs. This solves an issue where the character doesn't exist, but fits reference the pattern.
|
||||
try:
|
||||
logger.debug("Running database cleanup for orphaned characters attached to fits.")
|
||||
results = saveddata_engine.execute("SELECT COUNT(*) AS num FROM fits WHERE characterID NOT IN (SELECT ID FROM characters)")
|
||||
|
||||
count_results = 0
|
||||
for result in results:
|
||||
count_results = result[0]
|
||||
break
|
||||
|
||||
# Count how many records exist. This is ugly, but SQLAlchemy doesn't return a count from a select query.
|
||||
if results.fetchone()['num'] > 0:
|
||||
if count_results > 0:
|
||||
# Get All 5 character ID
|
||||
all5_results = saveddata_engine.execute("SELECT ID FROM characters WHERE name = 'All 5'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user