moved currency field from Sites to Gametypes&TourneyTypes, addded Sites.code
This commit is contained in:
parent
4d42953135
commit
de2d810ac5
|
@ -34,8 +34,8 @@ class Gametype(MappedBase):
|
|||
@staticmethod
|
||||
def get_or_create(session, siteId, gametype):
|
||||
map = zip(
|
||||
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet'],
|
||||
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', ])
|
||||
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet', 'currency'],
|
||||
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', 'currency'])
|
||||
gametype = dict([(new, gametype.get(old)) for new, old in map ])
|
||||
|
||||
hilo = "h"
|
||||
|
@ -340,18 +340,20 @@ class HandPlayer(MappedBase):
|
|||
class Site(object):
|
||||
"""Class reflecting Players db table"""
|
||||
INITIAL_DATA = [
|
||||
(1 , 'Full Tilt Poker','USD'),
|
||||
(2 , 'PokerStars', 'USD'),
|
||||
(3 , 'Everleaf', 'USD'),
|
||||
(4 , 'Win2day', 'USD'),
|
||||
(5 , 'OnGame', 'USD'),
|
||||
(6 , 'UltimateBet', 'USD'),
|
||||
(7 , 'Betfair', 'USD'),
|
||||
(8 , 'Absolute', 'USD'),
|
||||
(9 , 'PartyPoker', 'USD'),
|
||||
(10, 'Partouche', 'EUR'),
|
||||
(1 , 'Full Tilt Poker','FT'),
|
||||
(2 , 'PokerStars', 'PS'),
|
||||
(3 , 'Everleaf', 'EV'),
|
||||
(4 , 'Win2day', 'W2'),
|
||||
(5 , 'OnGame', 'OG'),
|
||||
(6 , 'UltimateBet', 'UB'),
|
||||
(7 , 'Betfair', 'BF'),
|
||||
(8 , 'Absolute', 'AB'),
|
||||
(9 , 'PartyPoker', 'PP'),
|
||||
(10, 'Partouche', 'PA'),
|
||||
(11, 'Carbon', 'CA'),
|
||||
(12, 'PKR', 'PK'),
|
||||
]
|
||||
INITIAL_DATA_KEYS = ('id', 'name', 'currency')
|
||||
INITIAL_DATA_KEYS = ('id', 'name', 'code')
|
||||
|
||||
INITIAL_DATA_DICTS = [ dict(zip(INITIAL_DATA_KEYS, datum)) for datum in INITIAL_DATA ]
|
||||
|
||||
|
@ -380,7 +382,7 @@ class TourneyType(MappedBase):
|
|||
|
||||
Required kwargs:
|
||||
buyin fee speed maxSeats knockout
|
||||
rebuyOrAddon headsUp shootout matrix sng
|
||||
rebuyOrAddon headsUp shootout matrix sng currency
|
||||
"""
|
||||
return get_or_create(cls, session, **kwargs)[0]
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ autorates_table = Table('Autorates', metadata,
|
|||
gametypes_table = Table('Gametypes', metadata,
|
||||
Column('id', SmallInteger, primary_key=True),
|
||||
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False), # SMALLINT
|
||||
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
|
||||
Column('type', String(4), nullable=False), # char(4) NOT NULL
|
||||
Column('base', String(4), nullable=False), # char(4) NOT NULL
|
||||
Column('category', String(9), nullable=False), # varchar(9) NOT NULL
|
||||
|
@ -338,7 +339,7 @@ settings_table = Table('Settings', metadata,
|
|||
sites_table = Table('Sites', metadata,
|
||||
Column('id', SmallInteger, primary_key=True),
|
||||
Column('name', String(32), nullable=False), # varchar(32) NOT NULL
|
||||
Column('currency', String(3), nullable=False), # char(3) NOT NULL
|
||||
Column('code', String(2), nullable=False), # char(2) NOT NULL
|
||||
mysql_charset='utf8',
|
||||
mysql_engine='InnoDB',
|
||||
)
|
||||
|
@ -374,6 +375,7 @@ Index('siteTourneyNo', tourneys_table.c.siteTourneyNo, tourneys_table.c.tourneyT
|
|||
tourney_types_table = Table('TourneyTypes', metadata,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False),
|
||||
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
|
||||
Column('buyin', Integer, nullable=False), # INT NOT NULL
|
||||
Column('fee', Integer, nullable=False, default=0), # INT NOT NULL
|
||||
Column('maxSeats', Boolean, nullable=False, default=-1), # INT NOT NULL DEFAULT -1
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Database.py
|
||||
|
||||
Create and manage the database objects.
|
||||
|
@ -1343,18 +1344,18 @@ class Database:
|
|||
def fillDefaultData(self):
|
||||
c = self.get_cursor()
|
||||
c.execute("INSERT INTO Settings (version) VALUES (%s);" % (DB_VERSION))
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Full Tilt Poker', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PokerStars', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Everleaf', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Win2day', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('OnGame', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('UltimateBet', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Betfair', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Absolute', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PartyPoker', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Partouche', 'EUR')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Carbon', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PKR', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Full Tilt Poker', 'FT')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PokerStars', 'PS')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Everleaf', 'EV')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Win2day', 'W2')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('OnGame', 'OG')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('UltimateBet', 'UB')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Betfair', 'BF')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Absolute', 'AB')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PartyPoker', 'PP')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Partouche', 'PA')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
|
||||
if self.backend == self.SQLITE:
|
||||
c.execute("INSERT INTO TourneyTypes (id, siteId, buyin, fee) VALUES (NULL, 1, 0, 0);")
|
||||
elif self.backend == self.PGSQL:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Returns a dict of SQL statements used in fpdb.
|
||||
"""
|
||||
# Copyright 2008-2009, Ray E. Barker
|
||||
|
@ -114,18 +115,18 @@ class Sql:
|
|||
self.query['createSitesTable'] = """CREATE TABLE Sites (
|
||||
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||
name varchar(32) NOT NULL,
|
||||
currency char(3) NOT NULL)
|
||||
code char(2) NOT NULL)
|
||||
ENGINE=INNODB"""
|
||||
elif db_server == 'postgresql':
|
||||
self.query['createSitesTable'] = """CREATE TABLE Sites (
|
||||
id SERIAL, PRIMARY KEY (id),
|
||||
name varchar(32),
|
||||
currency char(3))"""
|
||||
code char(2))"""
|
||||
elif db_server == 'sqlite':
|
||||
self.query['createSitesTable'] = """CREATE TABLE Sites (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
currency TEXT NOT NULL)"""
|
||||
code TEXT NOT NULL)"""
|
||||
|
||||
|
||||
################################
|
||||
|
@ -136,6 +137,7 @@ class Sql:
|
|||
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
|
||||
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
currency varchar(4) NOT NULL,
|
||||
type char(4) NOT NULL,
|
||||
base char(4) NOT NULL,
|
||||
category varchar(9) NOT NULL,
|
||||
|
@ -150,6 +152,7 @@ class Sql:
|
|||
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
|
||||
id SERIAL, PRIMARY KEY (id),
|
||||
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
currency varchar(4),
|
||||
type char(4),
|
||||
base char(4),
|
||||
category varchar(9),
|
||||
|
@ -163,6 +166,7 @@ class Sql:
|
|||
self.query['createGametypesTable'] = """CREATE TABLE GameTypes (
|
||||
id INTEGER PRIMARY KEY,
|
||||
siteId INTEGER,
|
||||
currency TEXT,
|
||||
type TEXT,
|
||||
base TEXT,
|
||||
category TEXT,
|
||||
|
@ -358,6 +362,7 @@ class Sql:
|
|||
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
|
||||
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
currency varchar(4) NOT NULL,
|
||||
buyin INT NOT NULL,
|
||||
fee INT NOT NULL,
|
||||
maxSeats INT NOT NULL DEFAULT -1,
|
||||
|
@ -374,6 +379,7 @@ class Sql:
|
|||
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
|
||||
id SERIAL, PRIMARY KEY (id),
|
||||
siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
currency varchar(4) NOT NULL,
|
||||
buyin INT NOT NULL,
|
||||
fee INT NOT NULL,
|
||||
maxSeats INT NOT NULL DEFAULT -1,
|
||||
|
@ -389,6 +395,7 @@ class Sql:
|
|||
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
|
||||
id INTEGER PRIMARY KEY,
|
||||
siteId INT NOT NULL,
|
||||
currency TEXT NOT NULL,
|
||||
buyin INT NOT NULL,
|
||||
fee INT NOT NULL,
|
||||
maxSeats INT NOT NULL DEFAULT -1,
|
||||
|
|
Loading…
Reference in New Issue
Block a user