Add back in sqlcoders changes for sqlite - fix Grapher
This commit is contained in:
parent
1dcecf4ae3
commit
4ef4d22c94
|
@ -20,6 +20,7 @@ import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
from time import *
|
from time import *
|
||||||
#import pokereval
|
#import pokereval
|
||||||
|
|
||||||
|
|
|
@ -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.get_cursor(), names, siteID) # inserts players as needed
|
playerIDs = fpdb_simple.recognisePlayerIDs(db, 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']
|
||||||
|
|
|
@ -984,14 +984,17 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
||||||
# result.append(tmp[0][0])
|
# result.append(tmp[0][0])
|
||||||
# return result
|
# return result
|
||||||
|
|
||||||
def recognisePlayerIDs(cursor, names, site_id):
|
def recognisePlayerIDs(db, names, site_id):
|
||||||
q = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in names]))
|
c = db.get_cursor()
|
||||||
cursor.execute(q, names) # get all playerids by the names passed in
|
q = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" %(site_id, " OR name=".join([db.sql.query['placeholder'] for n in names]))
|
||||||
ids = dict(cursor.fetchall()) # convert to dict
|
c.execute(q, names) # get all playerids by the names passed in
|
||||||
|
ids = dict(c.fetchall()) # convert to dict
|
||||||
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
|
||||||
if notfound: # insert them into database
|
if notfound: # insert them into database
|
||||||
c.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", [(n,) for n in notfound])
|
q_ins = "INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")"
|
||||||
|
q_ins = q_ins.replace('%s', db.sql.query['placeholder'])
|
||||||
|
c.executemany(q_ins, [(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]))
|
||||||
q2 = q2.replace('%s', db.sql.query['placeholder'])
|
q2 = q2.replace('%s', db.sql.query['placeholder'])
|
||||||
c.execute(q2, notfound) # get their new ids
|
c.execute(q2, notfound) # get their new ids
|
||||||
|
|
Loading…
Reference in New Issue
Block a user