diff --git a/pyfpdb/FpdbSQLQueries.py b/pyfpdb/FpdbSQLQueries.py index 55bf8c2e..f1981d71 100644 --- a/pyfpdb/FpdbSQLQueries.py +++ b/pyfpdb/FpdbSQLQueries.py @@ -599,37 +599,6 @@ class FpdbSQLQueries: ################################ - # Returns all cash game handIds and the money won(winnings is the final pot) - # by the playerId for a single site. - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): - self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers - INNER JOIN Players ON HandsPlayers.playerId = Players.id - INNER JOIN Hands ON Hands.id = HandsPlayers.handId - WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) - ORDER BY handStart""" - elif(self.dbname == 'SQLite'): - #Probably doesn't work. - self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers - INNER JOIN Players ON HandsPlayers.playerId = Players.id - INNER JOIN Hands ON Hands.id = HandsPlayers.handId - WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) - ORDER BY handStart""" - - # Returns the profit for a given ring game handId, Total pot - money invested by playerId - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): - self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions - INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id - INNER JOIN Players ON HandsPlayers.playerId = Players.id - WHERE Players.name = %s AND HandsPlayers.handId = %s - AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" - elif(self.dbname == 'SQLite'): - #Probably doesn't work. - self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions - INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id - INNER JOIN Players ON HandsPlayers.playerId = Players.id - WHERE Players.name = %s AND HandsPlayers.handId = %s - AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): self.query['getPlayerId'] = """SELECT id from Players where name = %s""" elif(self.dbname == 'SQLite'): diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index b5f0cc4e..6a897bad 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -124,8 +124,8 @@ follow : whether to tail -f the input""" hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d") hand.maxseats = 8 # assume 8-max until we see otherwise if m.group('TABLEATTRIBUTES'): - m2 = re.search("(\d+) max", m.group('TABLEATTRIBUTES')) - hand.maxseats = int(m2.group(1)) + m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES')) + hand.maxseats = int(m2.group(2)) # These work, but the info is already in the Hand class - should be used for tourneys though. # m.group('SB') # m.group('BB') diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 6745e9fc..1a62a37d 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -176,7 +176,10 @@ class GuiBulkImport(): # ComboBox - filter self.cbfilter = gtk.combo_box_new_text() self.cbfilter.append_text("passthrough") - self.cbfilter.append_text("Everleaf") + self.cbfilter.append_text("BetfairToFpdb") + self.cbfilter.append_text("EverleafToFpdb") + self.cbfilter.append_text("FulltiltToFpdb") + self.cbfilter.append_text("PokerStarsToFpdb") self.cbfilter.set_active(0) self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK) self.cbfilter.show() @@ -194,8 +197,8 @@ class GuiBulkImport(): self.load_button.show() # see how many hands are in the db and adjust accordingly - tcursor = db.db.cursor() - tcursor.execute("Select count(1) from Hands;") + tcursor = self.importer.fdb.db.cursor() + tcursor.execute("Select count(1) from Hands") row = tcursor.fetchone() tcursor.close() self.n_hands_in_db = row[0] @@ -207,11 +210,9 @@ class GuiBulkImport(): def main(argv=None): """main can also be called in the python interpreter, by supplying the command line as the argument. >>>import GuiBulkImport ->>>GuiBulkImport.main("-f ~/data/hands")""" +>>>GuiBulkImport.main(['-f'.'~/data/hands'])""" if argv is None: argv = sys.argv[1:] - else: - argv = argv.split(" ") def destroy(*args): # call back for terminating the main eventloop gtk.main_quit() @@ -230,8 +231,8 @@ def main(argv=None): (options, sys.argv) = parser.parse_args(args = argv) config = Configuration.Config() - db = fpdb_db.fpdb_db() - + db = None + settings = {} settings['minPrint'] = options.minPrint if os.name == 'nt': settings['os'] = 'windows' diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 20750b96..3fa677b6 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -82,7 +82,7 @@ class Hud: font = "Sans" if font_size == None: font_size = "8" - self.font = pango.FontDescription(font + " " + font_size) + self.font = pango.FontDescription("%s %s" % (font, font_size)) # do we need to add some sort of condition here for dealing with a request for a font that doesn't exist? game_params = config.get_game_parameters(self.poker_game) @@ -102,6 +102,7 @@ class Hud: self.main_window.set_title("%s FPDBHUD" % (self.table.name)) self.main_window.set_decorated(False) self.main_window.set_opacity(self.colors["hudopacity"]) + self.main_window.set_focus_on_map(False) self.ebox = gtk.EventBox() self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move") @@ -173,10 +174,11 @@ class Hud: self.main_window.move(x, y) adj = self.adj_seats(self.hand, self.config) loc = self.config.get_locations(self.table.site, self.max) - for i in xrange(1, self.max + 1): - (x, y) = loc[adj[i]] - if i in self.stat_windows: - self.stat_windows[i].relocate(x, y) + for i, w in enumerate(self.stat_windows): + if not type(w) == int: # how do we get pure ints in this list?? + (x, y) = loc[adj[i]] + w.relocate(x, y) + return True def on_button_press(self, widget, event): @@ -196,12 +198,12 @@ class Hud: s.window.destroy() self.stat_windows = {} # also kill any aux windows - [aux.destroy() for aux in self.aux_windows] + (aux.destroy() for aux in self.aux_windows) self.aux_windows = [] def reposition_windows(self, *args): if self.stat_windows != {} and len(self.stat_windows) > 0: - map(lambda x: x.window.move(x.x, x.y), self.stat_windows.itervalues()) + (x.window.move(x.x, x.y) for x in self.stat_windows.itervalues() if type(x) != int) return True def debug_stat_windows(self, *args): @@ -217,7 +219,7 @@ class Hud: new_layout[self.stat_windows[sw].adj - 1] = new_loc self.config.edit_layout(self.table.site, self.max, locations = new_layout) # ask each aux to save its layout back to the config object - [aux.save_layout() for aux in self.aux_windows] + (aux.save_layout() for aux in self.aux_windows) # save the config object back to the file print "saving new xml file" self.config.save() @@ -227,9 +229,9 @@ class Hud: # Need range here, not xrange -> need the actual list adj = range(0, self.max + 1) # default seat adjustments = no adjustment # does the user have a fav_seat? - try: - sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat)) - if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: + if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: + try: + sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat)) fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat sys.stderr.write("found fav seat = %d\n" % fav_seat) # actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name) @@ -237,12 +239,14 @@ class Hud: sys.stderr.write("found actual seat = %d\n" % actual_seat) for i in xrange(0, self.max + 1): j = actual_seat + i - if j > self.max: j = j - self.max + if j > self.max: + j = j - self.max adj[j] = fav_seat + i - if adj[j] > self.max: adj[j] = adj[j] - self.max - except Exception, inst: - sys.stderr.write("exception in adj!!!\n\n") - sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly + if adj[j] > self.max: + adj[j] = adj[j] - self.max + except Exception, inst: + sys.stderr.write("exception in adj!!!\n\n") + sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly return adj def get_actual_seat(self, name): @@ -286,10 +290,12 @@ class Hud: font = self.font) self.stats = [] - for i in xrange(0, config.supported_games[self.poker_game].rows + 1): - row_list = [''] * config.supported_games[self.poker_game].cols + game = config.supported_games[self.poker_game] + + for i in xrange(0, game.rows + 1): + row_list = [''] * game.cols self.stats.append(row_list) - for stat in config.supported_games[self.poker_game].stats: + for stat in game.stats: self.stats[config.supported_games[self.poker_game].stats[stat].row] \ [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name @@ -303,30 +309,30 @@ class Hud: self.update_table_position() for s in self.stat_dict: + statd = self.stat_dict[s] try: self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here self.max = 10 self.create(hand, config, self.stat_dict, self.cards) - self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] + self.stat_windows[statd['seat']].player_id = statd['player_id'] for r in xrange(0, config.supported_games[self.poker_game].rows): for c in xrange(0, config.supported_games[self.poker_game].cols): this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]] - number = Stats.do_stat(self.stat_dict, player = self.stat_dict[s]['player_id'], stat = self.stats[r][c]) - statstring = this_stat.hudprefix + str(number[1]) + this_stat.hudsuffix + number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c]) + statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix) + window = self.stat_windows[statd['seat']] if this_stat.hudcolor != "": self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) - self.stat_windows[self.stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) - - self.stat_windows[self.stat_dict[s]['seat']].label[r][c].set_text(statstring) + window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) + + window.label[r][c].set_text(statstring) if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? - self.stat_windows[self.stat_dict[s]['seat']].window.show_all() -# self.reposition_windows() - tip = self.stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ - number[3] + ", " + number[4] - Stats.do_tip(self.stat_windows[self.stat_dict[s]['seat']].e_box[r][c], tip) + window.window.show_all() + tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4]) + Stats.do_tip(window.e_box[r][c], tip) def topify_window(self, window): """Set the specified gtk window to stayontop in MS Windows.""" @@ -407,8 +413,9 @@ class Stat_Window: self.window.set_title("%s" % seat) self.window.set_property("skip-taskbar-hint", True) self.window.set_transient_for(parent.main_window) + self.window.set_focus_on_map(False) - self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False) + self.grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False) self.window.add(self.grid) self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) @@ -418,12 +425,12 @@ class Stat_Window: usegtkframes = self.useframes e_box = self.e_box label = self.label - for r in xrange(self.game.rows): + for r in xrange(game.rows): if usegtkframes: self.frame.append([]) e_box.append([]) label.append([]) - for c in xrange(self.game.cols): + for c in xrange(game.cols): if usegtkframes: self.frame[r].append( gtk.Frame() ) e_box[r].append( gtk.EventBox() ) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index fe2baa71..9f8d6244 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -54,7 +54,10 @@ class Aux_Window: pass def destroy(self): - self.container.destroy() + try: + self.container.destroy() + except: + pass ############################################################################ # Some utility routines useful for Aux_Windows @@ -342,11 +345,12 @@ class Flop_Mucked(Aux_Window): self.m_windows[i].set_focus_on_map(False) self.eb[i] = gtk.EventBox() self.eb[i].connect("button_press_event", self.button_press_cb) + self.m_windows[i].connect("configure_event", self.configure_event_cb, i) self.m_windows[i].add(self.eb[i]) self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')]) self.eb[i].add(self.seen_cards[i]) - self.m_windows[i].move(int(x) + self.hud.table.x, int(y) + self.hud.table.y) self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y) + self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) self.m_windows[i].set_opacity(float(self.params['opacity'])) self.m_windows[i].show_all() self.m_windows[i].hide() @@ -372,7 +376,7 @@ class Flop_Mucked(Aux_Window): self.seen_cards[i].set_from_pixbuf(scratch) # self.m_windows[i].show_all() self.m_windows[i].resize(1,1) - self.m_windows[i].present() + self.m_windows[i].show() self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True @@ -402,9 +406,8 @@ class Flop_Mucked(Aux_Window): def hide_mucked_cards(self): """Hide the mucked card windows.""" for (i, w) in self.m_windows.iteritems(): - self.positions[i] = w.get_position() w.hide() - self.displayed_cards = False + self.displayed_cards = False def button_press_cb(self, widget, event, *args): """Handle button clicks in the event boxes.""" @@ -413,6 +416,7 @@ class Flop_Mucked(Aux_Window): if event.state & gtk.gdk.SHIFT_MASK: self.timer_on = False self.expose_all() + return if event.button == 3: # right button event pass @@ -428,9 +432,12 @@ class Flop_Mucked(Aux_Window): window = widget.get_parent() window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) + def configure_event_cb(self, widget, event, i, *args): + self.positions[i] = widget.get_position() + def expose_all(self): for (i, cards) in self.hud.cards.iteritems(): - self.m_windows[i].present() + self.m_windows[i].show() self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True @@ -443,8 +450,6 @@ class Flop_Mucked(Aux_Window): new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) else: new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) - print "old locations =", self.params['layout'][self.hud.max] - print "saving locations =", new_locs self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs) if __name__== "__main__": diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 5cdd3d3b..b5931bde 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -337,7 +337,7 @@ class fpdb: new_ps_thread=GuiPositionalStats.GuiPositionalStats(self.db, self.config, self.querydict) self.threads.append(new_ps_thread) ps_tab=new_ps_thread.get_vbox() - self.add_and_display_tab(ps_tab, "Ppositional Stats") + self.add_and_display_tab(ps_tab, "Positional Stats") def tab_main_help(self, widget, data): diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 5fe28d4b..5ce23928 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -191,7 +191,6 @@ class Importer: tmpcursor = self.fdb.db.cursor() tmpcursor.execute("Select count(1) from Hands;") self.settings['handsInDB'] = tmpcursor.fetchone()[0] - tmpcursor.close() except: pass # if this fails we're probably doomed anyway if self.settings['handsInDB'] < 5000: return "drop" @@ -336,7 +335,7 @@ class Importer: else: isTourney=fpdb_simple.isTourney(hand[0]) if not isTourney: - fpdb_simple.filterAnteBlindFold(hand) + hand = fpdb_simple.filterAnteBlindFold(hand) self.hand=hand try: diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index cfd3404d..167c9c07 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -28,7 +28,7 @@ SQLITE = 4 fastStoreHudCache = True # set this to True to test the new storeHudCache routine -saveActions = True # set this to False to avoid storing action data +saveActions = True # set this to False to avoid storing action data # Pros: speeds up imports # Cons: no action data is saved, so you need to keep the hand histories # variance not available on stats page @@ -70,9 +70,10 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, import_options = config.get_import_parameters() saveActions = False if import_options['saveActions'] == 'False' else True - fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False + fastStoreHudCache = False if import_options['fastStoreHudCache'] == 'False' else True - #print "DEBUG: saveActions: %s fastStoreHudCache: %s" %(saveActions, fastStoreHudCache) +# print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) +# print "DEBUG: import_options = ", import_options t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 5a75af45..b5a7124b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -29,6 +29,7 @@ MYSQL_INNODB = 2 PGSQL = 3 SQLITE = 4 + # Data Structures for index and foreign key creation # drop_code is an int with possible values: 0 - don't drop for bulk import # 1 - drop during bulk import @@ -51,7 +52,7 @@ indexes = [ , [ # indexes for postgres (list index 3) {'tab':'Boardcards', 'col':'handId', 'drop':0} , {'tab':'Gametypes', 'col':'siteId', 'drop':0} - , {'tab':'Hands', 'col':'gametypeId', 'drop':1} + , {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09 , {'tab':'Hands', 'col':'siteHandNo', 'drop':0} , {'tab':'HandsActions', 'col':'handplayerId', 'drop':0} , {'tab':'HandsPlayers', 'col':'handId', 'drop':1} @@ -160,12 +161,13 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "dropping pg fk", fk['fktab'], fk['fkcol'] + #print "dropping pg fk", fk['fktab'], fk['fkcol'] try: - fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " - + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') + #print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol']) + fdb.cursor.execute("alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])) + print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) except: - pass + print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) else: print "Only MySQL and Postgres supported so far" return -1 @@ -180,15 +182,15 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "Index dropping disabled for postgresql." - print "dropping pg index ", idx['tab'], idx['col'] + #print "Index dropping disabled for postgresql." + #print "dropping pg index ", idx['tab'], idx['col'] # mod to use tab_col for index name? try: - print "drop index %s_%s_idx" % (idx['tab'],idx['col']) fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) - print "dropped pg index ", idx['tab'], idx['col'] + print "drop index %s_%s_idx" % (idx['tab'],idx['col']) + #print "dropped pg index ", idx['tab'], idx['col'] except: - pass + print "! failed drop index %s_%s_idx" % (idx['tab'],idx['col']) else: print "Only MySQL and Postgres supported so far" return -1 @@ -510,7 +512,8 @@ def convertCardValues(arr): map(convertCardValuesBoard, arr) #end def convertCardValues -card_map = { "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14} +# a 0-card is one in a stud game that we did not see or was not shown +card_map = { "0": 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14} #converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details def convertCardValuesBoard(arr): @@ -608,7 +611,7 @@ def filterAnteBlindFold(hand): if foldeeName in line: hand[i] = None - hand = [line for line in hand if line] + return [line for line in hand if line] #end def filterAnteFold def stripEOLspaces(str): @@ -651,7 +654,7 @@ def filterCrap(hand, isTourney): elif (hand[i].endswith("is connected")): hand[i] = False elif (hand[i].endswith("is disconnected")): - toRemove.append(hand[i]) + hand[i] = False elif (hand[i].find(" is low with [")!=-1): hand[i] = False elif (hand[i].endswith(" mucks")): @@ -694,7 +697,7 @@ def filterCrap(hand, isTourney): elif (hand[i].find(" said, \"")!=-1): hand[i] = False - if isTourney: + if isTourney and not hand[i] == False: if (hand[i].endswith(" is sitting out") and (not hand[i].startswith("Seat "))): hand[i] = False elif (hand[i].endswith(": sits out")): @@ -1408,11 +1411,14 @@ def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, ac #stores into table hands_actions #print "start of storeActions, actionNos:",actionNos #print " action_amounts:",action_amounts + inserts = [] for i in xrange(len(actionTypes)): #iterate through streets for j in xrange(len(actionTypes[i])): #iterate through names for k in xrange(len(actionTypes[i][j])): #iterate through individual actions of that player on that street - cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)" - , (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])) + # Add inserts into a list and let + inserts = inserts + [(handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])] + + cursor.executemany("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", inserts) #end def storeActions def store_board_cards(cursor, hands_id, board_values, board_suits):