Begin moving query functions into fpdb_db function
No idea whether the code actually works
This commit is contained in:
parent
a261517175
commit
3e49e87842
|
@ -86,6 +86,7 @@ Should not commit, and do minimal selects. Callers may want to cache commits
|
|||
db: a connected fpdb_db object"""
|
||||
# TODO:
|
||||
# Players - base playerid and siteid tuple
|
||||
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
||||
# HudCache data to come from DerivedStats class
|
||||
# HandsActions - all actions for all players for all streets - self.actions
|
||||
# BoardCards - ?
|
||||
|
|
|
@ -221,4 +221,22 @@ class fpdb_db:
|
|||
self.db.commit()
|
||||
print "Finished recreating tables"
|
||||
#end def recreate_tables
|
||||
#end class fpdb_db
|
||||
|
||||
def getSqlPlayerIDs(names, site_id):
|
||||
result = []
|
||||
notfound = []
|
||||
self.cursor.execute("SELECT name,id FROM Players WHERE name='%s'" % "' OR name='".join(names))
|
||||
tmp = dict(self.cursor.fetchall())
|
||||
for n in names:
|
||||
if n not in tmp:
|
||||
notfound.append(n)
|
||||
else:
|
||||
result.append(tmp[n])
|
||||
if notfound:
|
||||
cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound))
|
||||
cursor.execute("SELECT id FROM Players WHERE name='%s'" % "' OR name='".join(notfound))
|
||||
tmp = cursor.fetchall()
|
||||
for n in tmp:
|
||||
result.append(n[0])
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue
Block a user