create Database instance in import to pass into parser - will eventually replace fpdb_db
This commit is contained in:
parent
9b4e47df9a
commit
a2db28ebf2
|
@ -49,6 +49,7 @@ class Database:
|
||||||
self.import_options = c.get_import_parameters()
|
self.import_options = c.get_import_parameters()
|
||||||
self.type = db_params['db-type']
|
self.type = db_params['db-type']
|
||||||
self.backend = db_params['db-backend']
|
self.backend = db_params['db-backend']
|
||||||
|
self.db_server = db_params['db-server']
|
||||||
# where possible avoid creating new SQL instance by using the global one passed in
|
# where possible avoid creating new SQL instance by using the global one passed in
|
||||||
if sql == None:
|
if sql == None:
|
||||||
self.sql = SQL.Sql(type = self.type, db_server = db_params['db-server'])
|
self.sql = SQL.Sql(type = self.type, db_server = db_params['db-server'])
|
||||||
|
|
|
@ -31,6 +31,7 @@ import re
|
||||||
|
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import fpdb_db
|
import fpdb_db
|
||||||
|
import Database
|
||||||
import fpdb_parse_logic
|
import fpdb_parse_logic
|
||||||
import Configuration
|
import Configuration
|
||||||
|
|
||||||
|
@ -57,7 +58,8 @@ class Importer:
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.caller = caller
|
self.caller = caller
|
||||||
self.config = config
|
self.config = config
|
||||||
self.fdb = None
|
self.database = None # database will be the main db interface eventually
|
||||||
|
self.fdb = None # fdb may disappear or just hold the simple db connection
|
||||||
self.cursor = None
|
self.cursor = None
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.dirlist = {}
|
self.dirlist = {}
|
||||||
|
@ -75,6 +77,7 @@ class Importer:
|
||||||
self.settings.setdefault("minPrint", 30)
|
self.settings.setdefault("minPrint", 30)
|
||||||
self.settings.setdefault("handCount", 0)
|
self.settings.setdefault("handCount", 0)
|
||||||
|
|
||||||
|
self.database = Database.Database(self.config) # includes .connection and .sql variables
|
||||||
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
|
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.do_connect(self.config)
|
||||||
self.fdb.db.rollback()
|
self.fdb.db.rollback()
|
||||||
|
@ -392,8 +395,9 @@ class Importer:
|
||||||
self.hand=hand
|
self.hand=hand
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handsId = fpdb_parse_logic.mainParser(self.settings, self.fdb
|
handsId = fpdb_parse_logic.mainParser( self.settings, self.fdb
|
||||||
, self.siteIds[site], category, hand, self.config)
|
, self.siteIds[site], category, hand
|
||||||
|
, self.config, self.database )
|
||||||
self.fdb.db.commit()
|
self.fdb.db.commit()
|
||||||
|
|
||||||
stored += 1
|
stored += 1
|
||||||
|
|
|
@ -21,10 +21,13 @@ import fpdb_simple
|
||||||
import Database
|
import Database
|
||||||
|
|
||||||
#parses a holdem hand
|
#parses a holdem hand
|
||||||
def mainParser(settings, fdb, siteID, category, hand, config):
|
def mainParser(settings, fdb, siteID, category, hand, config, db = None):
|
||||||
backend = settings['db-backend']
|
backend = settings['db-backend']
|
||||||
#This is redundant - hopefully fdb will be a Database object in an interation soon
|
if db == None:
|
||||||
db = Database.Database(config, 'fpdb', '')
|
#This is redundant - hopefully fdb will be a Database object in an iteration soon
|
||||||
|
db = Database.Database(c = config, sql = None)
|
||||||
|
else:
|
||||||
|
db = db
|
||||||
category = fpdb_simple.recogniseCategory(hand[0])
|
category = fpdb_simple.recogniseCategory(hand[0])
|
||||||
|
|
||||||
base = "hold" if category == "holdem" or category == "omahahi" or category == "omahahilo" else "stud"
|
base = "hold" if category == "holdem" or category == "omahahi" or category == "omahahilo" else "stud"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user