Merge branch 'master' of git://git.assembla.com/fpdboz.git
Conflicts: pyfpdb/GuiBulkImport.py pyfpdb/fpdb_simple.py
This commit is contained in:
commit
f54da25d2b
1
pyfpdb/GuiBulkImport.py
Executable file → Normal file
1
pyfpdb/GuiBulkImport.py
Executable file → Normal file
|
@ -236,7 +236,6 @@ def main(argv=None):
|
||||||
if os.name == 'nt': settings['os'] = 'windows'
|
if os.name == 'nt': settings['os'] = 'windows'
|
||||||
else: settings['os'] = 'linuxmac'
|
else: settings['os'] = 'linuxmac'
|
||||||
|
|
||||||
# settings.update(config.get_db_parameters('fpdb'))
|
|
||||||
settings.update(config.get_db_parameters())
|
settings.update(config.get_db_parameters())
|
||||||
settings.update(config.get_tv_parameters())
|
settings.update(config.get_tv_parameters())
|
||||||
settings.update(config.get_import_parameters())
|
settings.update(config.get_import_parameters())
|
||||||
|
|
|
@ -59,7 +59,7 @@ class fpdb_db:
|
||||||
self.database=database
|
self.database=database
|
||||||
if backend==self.MYSQL_INNODB:
|
if backend==self.MYSQL_INNODB:
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database)
|
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True)
|
||||||
elif backend==self.PGSQL:
|
elif backend==self.PGSQL:
|
||||||
import psycopg2
|
import psycopg2
|
||||||
# If DB connection is made over TCP, then the variables
|
# If DB connection is made over TCP, then the variables
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
import os # todo: remove this once import_dir is in fpdb_import
|
import os # todo: remove this once import_dir is in fpdb_import
|
||||||
import sys
|
import sys
|
||||||
from time import time
|
from time import time, strftime
|
||||||
import traceback
|
import traceback
|
||||||
import math
|
import math
|
||||||
import datetime
|
import datetime
|
||||||
|
|
|
@ -1407,26 +1407,18 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
||||||
# return result
|
# return result
|
||||||
|
|
||||||
def recognisePlayerIDs(cursor, names, site_id):
|
def recognisePlayerIDs(cursor, names, site_id):
|
||||||
names = [n.encode("utf-8") for n in names]
|
q = "SELECT name,id FROM Players WHERE name=%s" % " OR name=".join(["%s" for n in names])
|
||||||
namestring = "name=%s"
|
cursor.execute(q, names) # get all playerids by the names passed in
|
||||||
for x in xrange(len(names)-1):
|
|
||||||
namestring += " OR name=%s"
|
|
||||||
# print "names=", names, "\nnamestring=", namestring
|
|
||||||
cursor.execute("SELECT name,id FROM Players WHERE %s" % namestring , names) # get all playerids by the names passed in
|
|
||||||
ids = dict(cursor.fetchall()) # convert to dict
|
ids = dict(cursor.fetchall()) # convert to dict
|
||||||
if len(ids) != len(names):
|
if len(ids) != len(names):
|
||||||
notfound = [n for n in names if n not in ids] # make list of names not in database
|
notfound = [n for n in names if n not in ids] # make list of names not in database
|
||||||
if notfound: # insert them into database
|
if notfound: # insert them into database
|
||||||
namestring = "name=%s"
|
|
||||||
for x in xrange(len(notfound)-1):
|
|
||||||
namestring += " OR name=%s"
|
|
||||||
# print "namestring=",namestring,"\nnotfound=", notfound
|
|
||||||
cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound))
|
cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound))
|
||||||
cursor.execute("SELECT name,id FROM Players WHERE %s" % namestring, notfound) # get their new ids
|
q2 = "SELECT name,id FROM Players WHERE name=%s" % " OR name=".join(["%s" for n in notfound])
|
||||||
|
cursor.execute(q2, notfound) # get their new ids
|
||||||
tmp = dict(cursor.fetchall())
|
tmp = dict(cursor.fetchall())
|
||||||
for n in tmp: # put them all into the same dict
|
for n in tmp: # put them all into the same dict
|
||||||
ids[n] = tmp[n]
|
ids[n] = tmp[n]
|
||||||
# print "ids=", ids
|
|
||||||
# return them in the SAME ORDER that they came in in the names argument, rather than the order they came out of the DB
|
# return them in the SAME ORDER that they came in in the names argument, rather than the order they came out of the DB
|
||||||
return [ids[n] for n in names]
|
return [ids[n] for n in names]
|
||||||
#end def recognisePlayerIDs
|
#end def recognisePlayerIDs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user