From 4445881bfe11e78500083e3c5237a34d6b15472d Mon Sep 17 00:00:00 2001 From: eblade Date: Fri, 7 Aug 2009 17:18:51 -0400 Subject: [PATCH] somehow a call to get_cursor() got turned into just a db pass .. and removed the debug code in recogniseplayerids --- pyfpdb/fpdb_parse_logic.py | 2 +- pyfpdb/fpdb_simple.py | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index 696f42d2..815f3975 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -93,7 +93,7 @@ def mainParser(settings, siteID, category, hand, config, db = None, writeq = Non seatLines.append(line) names = fpdb_simple.parseNames(seatLines) - playerIDs = fpdb_simple.recognisePlayerIDs(db, names, siteID) # inserts players as needed + playerIDs = fpdb_simple.recognisePlayerIDs(db.get_cursor(), names, siteID) # inserts players as needed tmp = fpdb_simple.parseCashesAndSeatNos(seatLines) startCashes = tmp['startCashes'] seatNos = tmp['seatNos'] diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 76ce3fca..1f7d355a 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -985,28 +985,19 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon): # return result def recognisePlayerIDs(cursor, names, site_id): -# print "\nrecognisePlayerIDs names=",len(names),names q = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in names])) -# print "q=",q cursor.execute(q, names) # get all playerids by the names passed in ids = dict(cursor.fetchall()) # convert to dict -# print "ids(1)=",len(ids),ids if len(ids) != len(names): notfound = [n for n in names if n not in ids] # make list of names not in database -# print "notfound=", notfound if notfound: # insert them into database cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", [(n,) for n in notfound]) q2 = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in notfound])) cursor.execute(q2, notfound) # get their new ids tmp = cursor.fetchall() -# print "tmp=", tmp for n,id in tmp: # put them all into the same dict ids[n] = id # return them in the SAME ORDER that they came in in the names argument, rather than the order they came out of the DB -# print "ids=",ids -# list = [ids[n] for n in names] -# print "list=",list -# print "\n" return [ids[n] for n in names] #end def recognisePlayerIDs