From 300340218b030671620b05b0aecb973ab50b4035 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Mon, 28 Mar 2011 18:34:05 +0000 Subject: [PATCH 1/4] specifiying 'utf8' CHARSET in Players.name field not required and will lead to a conflict if mysql database created using a different utf-8 collation --- pyfpdb/SQL.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index e5b4c3d8..ee379fde 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -287,11 +287,11 @@ class Sql: if db_server == 'mysql': self.query['createPlayersTable'] = """CREATE TABLE Players ( - id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), - name VARCHAR(32) CHARACTER SET utf8 NOT NULL, - siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), - comment text, - commentTs DATETIME) + id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + name VARCHAR(32) NOT NULL, + siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), + comment text, + commentTs DATETIME) ENGINE=INNODB""" elif db_server == 'postgresql': self.query['createPlayersTable'] = """CREATE TABLE Players ( From 38fbae957ad408123b5ae6c2590aeb305c649978 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Tue, 29 Mar 2011 06:10:07 +0000 Subject: [PATCH 2/4] charset needs to be set to 'utf8' for the MySQL connection to store unicode strings correctly --- pyfpdb/Database.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 38eb802e..5481d9b9 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -399,7 +399,12 @@ class Database: if use_pool: MySQLdb = pool.manage(MySQLdb, pool_size=5) try: - self.connection = MySQLdb.connect(host=host, user=user, passwd=password, db=database, use_unicode=True) + self.connection = MySQLdb.connect(host=host + ,user=user + ,passwd=password + ,db=database + ,charset='utf8' + ,use_unicode=True) self.__connected = True #TODO: Add port option except MySQLdb.Error, ex: From b00c30cbbf3627d12b5dec2345e1f42d43504799 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Tue, 29 Mar 2011 14:18:00 +0000 Subject: [PATCH 3/4] Re-did patch to fix import when no hero is defined --- pyfpdb/Database.py | 2 +- pyfpdb/Hand.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 13496b61..5481d9b9 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1890,7 +1890,7 @@ class Database: if doinsert: for h in hbulk: id = h.pop() - if (hdata['sc'] != None and hdata['sc']['bk']) and hdata['gsc']['bk']: + if hdata['sc'] and hdata['gsc']: h[4] = hdata['sc'][id]['id'] h[5] = hdata['gsc'][id]['id'] q = self.sql.query['store_hand'] diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index cd00a985..58fb433d 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -306,9 +306,9 @@ dealt whether they were seen in a 'dealt to' line sc = db.prepSessionsCache(self.dbid_hands, self.dbid_pids, self.startTime, sc, self.heros, doinsert) gsc = db.storeSessionsCache(self.dbid_hands, self.dbid_pids, self.startTime, self.gametype ,self.dbid_gt, self.handsplayers, sc, gsc, tz, self.heros, doinsert) - if doinsert: - self.hands['sc'] = sc - self.hands['gsc'] = gsc + if doinsert and sc['bk'] and gsc['bk']: + self.hands['sc'] = sc + self.hands['gsc'] = gsc else: self.hands['sc'] = None self.hands['gsc'] = None From c19549b3da6935b4dedbc1667e72ff6cc5c425f0 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Tue, 29 Mar 2011 20:15:21 +0000 Subject: [PATCH 4/4] changed the currency substitutions to byte stream AND unicode -- i.e. u'$|\xe2\x82\xac|\u20ac|' --- pyfpdb/FullTiltPokerSummary.py | 8 ++++---- pyfpdb/PacificPokerToFpdb.py | 4 ++-- pyfpdb/PokerStarsToFpdb.py | 4 ++-- pyfpdb/WinamaxSummary.py | 4 ++-- pyfpdb/WinamaxToFpdb.py | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pyfpdb/FullTiltPokerSummary.py b/pyfpdb/FullTiltPokerSummary.py index c06042d0..ab7ff266 100644 --- a/pyfpdb/FullTiltPokerSummary.py +++ b/pyfpdb/FullTiltPokerSummary.py @@ -44,10 +44,10 @@ class FullTiltPokerSummary(TourneySummary): } substitutions = { - 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes - 'LS' : "\$|\xe2\x82\xac|", # legal currency symbols - Euro(cp1252, utf-8) - 'TAB' : u"-\u2013'\s\da-zA-Z", # legal characters for tablename - 'NUM' : u".,\d", # legal characters in number format + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20ac|", # legal currency symbols - Euro(cp1252, utf-8) + 'TAB' : u"-\u2013'\s\da-zA-Z", # legal characters for tablename + 'NUM' : u".,\d", # legal characters in number format } re_SplitTourneys = re.compile("^Full Tilt Poker Tournament Summary") diff --git a/pyfpdb/PacificPokerToFpdb.py b/pyfpdb/PacificPokerToFpdb.py index a46ea739..3989eea4 100644 --- a/pyfpdb/PacificPokerToFpdb.py +++ b/pyfpdb/PacificPokerToFpdb.py @@ -41,8 +41,8 @@ class PacificPoker(HandHistoryConverter): mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3", "play": ""} # ADD Euro, Sterling, etc HERE substitutions = { - 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes - 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20ac|" # legal currency symbols - Euro(cp1252, utf-8) } # translations from captured groups to fpdb info strings diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 72c96d71..103b45b0 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -41,8 +41,8 @@ class PokerStars(HandHistoryConverter): mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3", "play": ""} # ADD Euro, Sterling, etc HERE substitutions = { - 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes - 'LS' : u"\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20ac|" # legal currency symbols - Euro(cp1252, utf-8) } # translations from captured groups to fpdb info strings diff --git a/pyfpdb/WinamaxSummary.py b/pyfpdb/WinamaxSummary.py index e1d5b0ce..3d001308 100644 --- a/pyfpdb/WinamaxSummary.py +++ b/pyfpdb/WinamaxSummary.py @@ -44,8 +44,8 @@ class WinamaxSummary(TourneySummary): } substitutions = { - 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes - 'LS' : u"\$|\xe2\x82\xac|\u20AC|" # legal currency symbols + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20ac|" # legal currency symbols } re_GameType = re.compile("""

((?PNo Limit|Pot Limit) (?PHold\'em))

""") diff --git a/pyfpdb/WinamaxToFpdb.py b/pyfpdb/WinamaxToFpdb.py index b01df4ec..65dbb1df 100644 --- a/pyfpdb/WinamaxToFpdb.py +++ b/pyfpdb/WinamaxToFpdb.py @@ -54,8 +54,8 @@ class Winamax(HandHistoryConverter): mixes = { } # Legal mixed games sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE substitutions = { - 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes - 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20ac|" # legal currency symbols - Euro(cp1252, utf-8) } limits = { 'no limit':'nl', 'pot limit' : 'pl','LIMIT':'fl'}