somehow a call to get_cursor() got turned into just a db pass .. and removed the debug code in recogniseplayerids
This commit is contained in:
parent
43b41e88f4
commit
4445881bfe
|
@ -93,7 +93,7 @@ def mainParser(settings, siteID, category, hand, config, db = None, writeq = Non
|
||||||
seatLines.append(line)
|
seatLines.append(line)
|
||||||
|
|
||||||
names = fpdb_simple.parseNames(seatLines)
|
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)
|
tmp = fpdb_simple.parseCashesAndSeatNos(seatLines)
|
||||||
startCashes = tmp['startCashes']
|
startCashes = tmp['startCashes']
|
||||||
seatNos = tmp['seatNos']
|
seatNos = tmp['seatNos']
|
||||||
|
|
|
@ -985,28 +985,19 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
||||||
# return result
|
# return result
|
||||||
|
|
||||||
def recognisePlayerIDs(cursor, names, site_id):
|
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]))
|
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
|
cursor.execute(q, names) # get all playerids by the names passed in
|
||||||
ids = dict(cursor.fetchall()) # convert to dict
|
ids = dict(cursor.fetchall()) # convert to dict
|
||||||
# print "ids(1)=",len(ids),ids
|
|
||||||
if len(ids) != len(names):
|
if len(ids) != len(names):
|
||||||
notfound = [n for n in names if n not in ids] # make list of names not in database
|
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
|
if notfound: # insert them into database
|
||||||
cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", [(n,) for n in notfound])
|
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]))
|
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
|
cursor.execute(q2, notfound) # get their new ids
|
||||||
tmp = cursor.fetchall()
|
tmp = cursor.fetchall()
|
||||||
# print "tmp=", tmp
|
|
||||||
for n,id in tmp: # put them all into the same dict
|
for n,id in tmp: # put them all into the same dict
|
||||||
ids[n] = id
|
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
|
# 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]
|
return [ids[n] for n in names]
|
||||||
#end def recognisePlayerIDs
|
#end def recognisePlayerIDs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user