def getNumeroLote(compania,fecha ,cnxn):
sql = "select ISNULL( MAX(SUBSTRING(lotNumLote,7,2)) , 0) as lote from Lotesxbanco where lotCodCompania = %s and SUBSTRING(lotNumLote,1,6) = %d"
params = (compania, fecha)
result = cnxn.cursor().execute(sql, params)
res = result.fetchone
return res[0]