From 75221f0b6ac5d266be0ecdeb103f2569959f3e02 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 7 May 2009 21:24:06 +0100 Subject: [PATCH 1/4] oops, missed out the key change in previous commit --- pyfpdb/fpdb_db.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index eba87f52..fda04e19 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -62,6 +62,8 @@ class fpdb_db: self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True) elif backend==self.PGSQL: import psycopg2 + import psycopg2.extensions + psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) # If DB connection is made over TCP, then the variables # host, user and password are required print "host=%s user=%s pass=%s." % (host, user, password) From 0b29286c9d029885c1c9c5a18fdbc9f7bf912898 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 26 Apr 2009 21:31:05 +0100 Subject: [PATCH 2/4] fix 3bet stat bug in storeHudCache2 --- pyfpdb/fpdb_simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 609e3b4c..9c0e7845 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -2498,7 +2498,7 @@ def storeHudCache2(backend, cursor, base, category, gametypeId, playerIds, hudIm # Try to do the update first: num = cursor.execute("""UPDATE HudCache SET HDs=HDs+%s, street0VPI=street0VPI+%s, street0Aggr=street0Aggr+%s, - street0_3B4BChance=%s, street0_3B4BDone=%s, + street0_3B4BChance=street0_3B4BChance+%s, street0_3B4BDone=street0_3B4BDone+%s, street1Seen=street1Seen+%s, street2Seen=street2Seen+%s, street3Seen=street3Seen+%s, street4Seen=street4Seen+%s, sawShowdown=sawShowdown+%s, street1Aggr=street1Aggr+%s, street2Aggr=street2Aggr+%s, street3Aggr=street3Aggr+%s, From d811c6b656dd43829b7bfa76e61af6adea1793d4 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 26 Apr 2009 21:38:04 +0100 Subject: [PATCH 3/4] add rollback to release locks when db reads are finished --- pyfpdb/fpdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 49b3ad82..168a75d8 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -287,6 +287,7 @@ class fpdb: # Database connected to successfully, load queries to pass on to other classes self.querydict = FpdbSQLQueries.FpdbSQLQueries(self.db.get_backend_name()) + self.db.db.rollback() #end def load_profile def not_implemented(self): @@ -296,7 +297,7 @@ class fpdb: def obtain_global_lock(self): print "todo: implement obtain_global_lock (users: pls ignore this)" #end def obtain_global_lock - + def quit(self, widget, data): print "Quitting normally" #check if current settings differ from profile, if so offer to save or abort @@ -341,7 +342,6 @@ class fpdb: ps_tab=new_ps_thread.get_vbox() self.add_and_display_tab(ps_tab, "Positional Stats") - def tab_main_help(self, widget, data): """Displays a tab with the main fpdb help screen""" #print "start of tab_main_help" From f0b4d82fa554c678f5df0e847083fb8c3bbd0bfa Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 26 Apr 2009 21:47:28 +0100 Subject: [PATCH 4/4] always release locks when db work finished --- pyfpdb/fpdb_import.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 6c0af7f5..6d2f846d 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -73,6 +73,7 @@ class Importer: self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql self.fdb.do_connect(self.config) + self.fdb.db.rollback() #Set functions def setCallHud(self, value): @@ -367,6 +368,7 @@ class Importer: self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep) except fpdb_simple.DuplicateError: duplicates += 1 + self.fdb.db.rollback() except (ValueError), fe: errors += 1 self.printEmailErrorMessage(errors, file, hand) @@ -374,6 +376,8 @@ class Importer: if (self.settings['failOnError']): self.fdb.db.commit() #dont remove this, in case hand processing was cancelled. raise + else: + self.fdb.db.rollback() except (fpdb_simple.FpdbError), fe: errors += 1 self.printEmailErrorMessage(errors, file, hand)