def findPlayer(targetID):
    global cursor
    if cursor == None:
        cursor = SQLHelper.connectToSource().cursor()
    query = """select PlayerID from Players where PlayerID = %s or PlayerID =%s%s or GamerTag like %s order by missions desc limit 1"""
    prefix = cfg.getConfigString("ID Prefix")
    data = (targetID, prefix, targetID, '%%%s%%' % (targetID))
    cursor.execute(query, data)
    result = cursor.fetchone()

    if result != None and len(result) == 1:
        return result[0]
    return "0-0-0"
from DBG import DBG
import math
import ConfigHelper as cfg
import SQLHelper
import colorama
from colorama import Fore, Back
import feedbackQueue
from psycopg2 import sql

#: last 5 games' stats
#: Blobs, month to month.
#: Top achievement in terms of rarity
#: most recent achievements
#: Places visited
conn = SQLHelper.connectToSource()
cursor = conn.cursor()

colorama.init()

#https://codegolf.stackexchange.com/questions/4707/outputting-ordinal-numbers-1st-2nd-3rd#answer-4712
ordinal = [
    '0th',
    '%s%s1st%s%s' % (Fore.BLACK, Back.YELLOW, Fore.YELLOW, Back.BLACK),
    '%s%s2nd%s%s' % (Fore.BLACK, Back.WHITE, Fore.YELLOW, Back.BLACK),
    '%s%s3rd%s%s' % (Fore.BLACK, Back.RED, Fore.YELLOW, Back.BLACK), '4th',
    '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th',
    '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd',
    '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st', '32nd',
    '33rd', '34th', '35th', '36th', '37th', '38th', '39th', '40th', '41st',
    '42nd', '43rd', '44th', '45th', '46th', '47th', '48th', '49th', '50th'
]