summaryrefslogtreecommitdiff
path: root/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'sql.py')
-rw-r--r--sql.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/sql.py b/sql.py
index 89e5c5d..90befa9 100644
--- a/sql.py
+++ b/sql.py
@@ -71,11 +71,12 @@ def save_player(token, mask=SQL_NONE):
Player[token]["aptime"],
Player[token]["userid"])
- stdout(sqlx)
+ stdout(sqlx, 2)
try:
w.execute(sqlx)
except:
- stdout("SQL.ERR: Error happened (save.player), commiting anyway due MyISAM...")
+ stdout("SQL.ERR: Error happened (save.player), commiting anyway due MyISAM...", 0)
+ stdout("Faulty: %s" % sqlx, 0)
#w.execute("INSERT INTO ....") # <- Not in save_player
#w.execute("REPLACE DELAYED....") # <- Not where you can't delete, but for inv
@@ -128,7 +129,7 @@ def save_inv(token, mask=SQL_NONE, force=False):
w.execute("""DELETE FROM `inventory`
WHERE `userid` = %d AND `index` = %d"""
% (uid, i))
- stdout("SQL.INV: Delete where uid %d and index %d" % (uid, i))
+ stdout("SQL.INV: Delete where uid %d and index %d" % (uid, i), 2)
i+=1
continue
@@ -140,7 +141,7 @@ def save_inv(token, mask=SQL_NONE, force=False):
% (m, uid, i, it["unit_id"], it["level"], it["exp"]))
except:
# Something went wrong!
- print("ERROR Saving item index %d for player %d: %s\n%s" % (i, uid, str(it), fatalmsg))
+ stdout("ERROR Saving item index %d for player %d: %s\n%s" % (i, uid, str(it), fatalmsg), 0)
if not force:
revert=True
finally:
@@ -149,14 +150,14 @@ def save_inv(token, mask=SQL_NONE, force=False):
# If something went wrong, don't save inventory
if revert:
#db.rollback()
- stdout("SQL.ERR: Error happened, commiting anyway due MyISAM...")
+ stdout("SQL.ERR: Error happened, commiting anyway due MyISAM...", 0)
# We should now remove every item with an index higher than length
# In case the inventory shrink without None's taking the place...
w.execute("""DELETE FROM `inventory`
WHERE `userid` = %d AND `index` >= %d"""
% (uid, len(inv)))
- stdout("SQL.INV: delete indexes >= %d, committing changes" % len(inv))
+ stdout("SQL.INV: delete indexes >= %d, committing changes" % len(inv), 2)
db.commit()
w.close()
@@ -190,10 +191,10 @@ def save_party(token, mask=SQL_NONE):
Player[token]["party_%d" % i][3]["inv_id"],
Player[token]["userid"], i)
- stdout(sqlx)
+ stdout(sqlx, 2)
w.execute(sqlx)
except:
- print("[SQL ERROR] Impossible to save party %d" % i)
+ stdout("[SQL ERROR] Impossible to save party %d" % i, 0)
db.rollback()
i+=1
@@ -354,7 +355,7 @@ def keep_alive():
db.ping(reconnect=True, attempts=10, delay=1)
except:
# SQL error
- stdout("keep_alive: INTERNAL ERROR")
+ stdout("keep_alive: INTERNAL ERROR", 0)
db.reconnect(attempts=12, delay=10)
sql_keep_alive=threading.Timer(SQL_PINGTIME, keep_alive)
sql_keep_alive.daemon=True