mirror of https://github.com/axmolengine/axmol.git
add exception guard to db operation
This commit is contained in:
parent
60a6039666
commit
b70ddc7a14
|
@ -69,18 +69,27 @@ def connect_db():
|
||||||
db_user = os.environ['db_user']
|
db_user = os.environ['db_user']
|
||||||
db_pw = os.environ['db_pw']
|
db_pw = os.environ['db_pw']
|
||||||
db_name=os.environ['db_name']
|
db_name=os.environ['db_name']
|
||||||
db = MySQLdb.connect(db_host, db_user, db_pw, db_name)
|
try:
|
||||||
|
db = MySQLdb.connect(db_host, db_user, db_pw, db_name)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def close_db(db):
|
def close_db(db):
|
||||||
db.close()
|
try:
|
||||||
|
db.close()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def save_build_stats(db, pr, filename, size):
|
def save_build_stats(db, pr, filename, size):
|
||||||
cursor = db.cursor()
|
try:
|
||||||
sql = "INSERT INTO `%s` (number, size, createdTime) VALUES(%d, %d, now())" % (filename, pr, size)
|
cursor = db.cursor()
|
||||||
print sql
|
sql = "INSERT INTO `%s` (number, size, createdTime) VALUES(%d, %d, now())" % (filename, pr, size)
|
||||||
cursor.execute(sql)
|
print sql
|
||||||
db.commit()
|
cursor.execute(sql)
|
||||||
|
db.commit()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def scan_all_libs(db, pr_num):
|
def scan_all_libs(db, pr_num):
|
||||||
stats = {}
|
stats = {}
|
||||||
|
|
Loading…
Reference in New Issue