Commit bcc9a7e0 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Bug fix in DBQuery(). Return the query results to the user. Note that

this function is backwards; DBQueryFatal() should call DBQuery(), not
the other way around!

Remove some debugging stuff that broke the library. Kirk can add it
back later when he decides what to do.
parent 39772379
......@@ -17,6 +17,7 @@ from libtestbed import *
__dbName = "@TBDBNAME@"
__dbQueryMaxtries = 1
__dbConnMaxtries = 5
__debug = 0
__dbConnection = None
......@@ -34,7 +35,7 @@ def TBDBConnect():
name = "uid%d" % uid
dbuser = "%s:%s:%d" % (sys.argv[0], name, os.getpid())
if libtestbed.gv.debug:
if __debug:
print "Connecting to db %s as %s" % (__dbName, dbuser)
# Connect, with retries
......@@ -56,7 +57,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
else:
cursor = __dbConnection.cursor()
if libtestbed.gv.debug:
if __debug:
print "Executing DB query %s" % queryPat
tries = __dbQueryMaxtries
......@@ -64,7 +65,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
try:
cursor.execute(queryPat, querySub)
ret = cursor.fetchall()
if libtestbed.gv.debug:
if __debug:
rs = `ret`
if len(rs) > 60:
rs = rs[:60] + "..."
......@@ -86,6 +87,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
def DBQuery(*args):
try:
ret = DBQueryFatal(*args)
return ret
except MySQLdb.MySQLError:
return None
......@@ -17,6 +17,7 @@ from libtestbed import *
__dbName = "@TBDBNAME@"
__dbQueryMaxtries = 1
__dbConnMaxtries = 5
__debug = 0
__dbConnection = None
......@@ -34,7 +35,7 @@ def TBDBConnect():
name = "uid%d" % uid
dbuser = "%s:%s:%d" % (sys.argv[0], name, os.getpid())
if libtestbed.gv.debug:
if __debug:
print "Connecting to db %s as %s" % (__dbName, dbuser)
# Connect, with retries
......@@ -56,7 +57,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
else:
cursor = __dbConnection.cursor()
if libtestbed.gv.debug:
if __debug:
print "Executing DB query %s" % queryPat
tries = __dbQueryMaxtries
......@@ -64,7 +65,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
try:
cursor.execute(queryPat, querySub)
ret = cursor.fetchall()
if libtestbed.gv.debug:
if __debug:
rs = `ret`
if len(rs) > 60:
rs = rs[:60] + "..."
......@@ -86,6 +87,7 @@ def DBQueryFatal(queryPat, querySub = (), asDict = False):
def DBQuery(*args):
try:
ret = DBQueryFatal(*args)
return ret
except MySQLdb.MySQLError:
return None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment