コード例 #1
0
ファイル: sqlAccessors.py プロジェクト: alclass/cxlots
def getAttrs(attrs, table='ms', nDoConc=1):
  '''
  getAttrs() method
  '''
  tt = type(table)
  if tt == CLClasses.Base:
    table = table.sqlTable
  if tt == CLClasses.Jogos:
    table = table.sqlTable

  sqlAttrs = ''
  for attr in attrs:
    sqlAttrs += '`%s`,' %(attr)
  sqlAttrs = sqlAttrs[:-1] # to strip the ending ',' (comma)

  sql = '''SELECT %(sqlAttrs)s FROM `%(table)s` 
    WHERE `nDoConc` >= '%(nDoConc)d'
    ORDER BY `nDoConc`;''' %{'sqlAttrs':sqlAttrs,'table':table,'nDoConc':nDoConc}

  print sql

  #sys.exit(0)
  conn = fSql.getConnection()
  cursor = conn.cursor()
  cursor.execute(sql)
  #rows = cursor._rows
  # fields = map(lambdas.lambdaExtractFirstElem, rows)
  outRows = []
  for cols in cursor:
    i=-1; attrDict = {}
    for attr in attrs:
      i+=1
      attrDict[attr] = cols[i]
    outRows.append(attrDict)
  return outRows
コード例 #2
0
ファイル: sqlAccessors.py プロジェクト: alclass/cxlots
def getAttr(field, table='ms', nDoConc=1):
  '''
  getAttr() method
  '''
  tt = type(table)
  if tt == CLClasses.Base:
    table = table.sqlTable
  if tt == CLClasses.Jogos:
    table = table.sqlTable
  sql = "SELECT `%(field)s` FROM `%(table)s` WHERE `nDoConc` >= '%(nDoConc)d';" %{'field':field,'table':table,'nDoConc':nDoConc}
  print sql
  #sys.exit(0)
  conn = fSql.getConnection()
  cursor = conn.cursor()
  cursor.execute(sql)
  rows = []; fields = []; fieldDict = {}
  # fields = map(lambdas.lambdaExtractFirstElem, rows)
  for row in cursor:
    rows.append(row)
  for cols in rows:
    field = cols[0]
    fields.append(field)
    try:
      fieldDict[field]+=1
    except KeyError:
      fieldDict[field]=1
  return fieldDict, fields
コード例 #3
0
ファイル: Stat.py プロジェクト: alclass/cxlots
  def gatherStats(self):
    self.til5obj  = tilc.Til(self.jogosObj, 5)
    self.til6obj  = tilc.Til(self.jogosObj, 6)
    self.til10obj = tilc.Til(self.jogosObj, 10)
    self.radii    = Radii.Radii(self.jogosObj.standard2LetterName)
    jogos = self.jogosObj.getJogos()
    if not self.updateAll:
      didIt = self.moveNDoConcForStatUpdate()
      if not didIt:
        # this happens if there's nothing to update
        return 0

    self.conn = fSql.getConnection()
    self.runAllIndividualStats()
    return self.nOfUpdated
    if self.logIt:
      self.logFile.close()
    self.conn.close()
コード例 #4
0
ファイル: sqlAccessors.py プロジェクト: alclass/cxlots
def getAttrFor(field, table='ms', nDoConc=1):
  '''
  getAttrFor() method
  '''
  if field == None:
    return None
  sql = "SELECT `%(field)s` FROM `%(table)s` WHERE `nDoConc` = '%(nDoConc)d';" %{'field':field,'table':table,'nDoConc':nDoConc}
  #print sql
  #sys.exit(0)
  conn = fSql.getConnection()
  cursor = conn.cursor()
  cursor.execute(sql)
  rows = []
  for row in cursor:
    rows.append(row)
  # fields = map(lambdas.lambdaExtractFirstElem, rows)
  if len(rows) == 1:
    return rows[0][0]
  return None
コード例 #5
0
ファイル: Stat.py プロジェクト: alclass/cxlots
 def moveNDoConcForStatUpdate(self):
   sql = '''SELECT `nDoConc` from `%s`
 where `iguaisComOAnterior` is NULL 
 and `nDoConc` > 1 
 order by `nDoConc`;
 '''  %(self.jogosObj.sqlTable)
   #print sql
   conn = fSql.getConnection()
   cursor = conn.cursor()
   cursor.execute(sql)
   rows = []
   for row in cursor:
     rows.append(row)
   if len(rows) > 0:
     VARRE_DO_JOGO = rows[0][0]
     #print 'VARRE_DO_JOGO ', VARRE_DO_JOGO 
     self.setVarreDe(VARRE_DO_JOGO)
     return True
   return False