def checkNotExist(self,table='',condition={}): conn,cursor = self.connectToServer() statement = mysql_utility.sqlQueryState(table,condition) cursor.execute(statement) conn.commit() result = cursor.fetchall() if len(result) == 0: return 1 else: return 0
def tableQuery(self, table='', tableList=[]): tempDict = {} conn, cursor = self.connectToServer() query_statement = mysql_utility.sqlQueryState(table) cursor.execute(query_statement) conn.commit() result = cursor.fetchall() for row in result: tempDict[row[0]] = dict(zip(tableList[1:], row[1:])) return tempDict
def queryServer(self,table='',tabHeader=[]): tempDict = {} conn,cursor = self.connectToServer() query_statement = mysql_utility.sqlQueryState(table) cursor.execute(query_statement) conn.commit() result = cursor.fetchall() if len(result) != 0: for row in result: tempDict[row[0]] = dict(zip(tabHeader,row)) cursor.close() conn.close() return tempDict
def queryOvertime(self,table='',date=(),member='',project='',subproject=''): loginfile = open('hostname','r').read().split(' ') hostid = loginfile[0] database = loginfile[1] user = loginfile[2] pwd = loginfile[3] if hostid[:3] == BOM_UTF8: hostid = hostid[3:] conn = sql.connect(hostid,user,pwd,database,charset='utf8') cursor = conn.cursor() query_condition = {u'日期':date,u'姓名':member,u'项目':project,u'展项':subproject} querystatement = mysql_utility.sqlQueryState(table,query_condition) cursor.execute(querystatement) conn.commit() result = cursor.fetchall() cursor.close() return result
def getDailyFromServer(self): self.dailyDict = {} conn,cursor = self.connectToServer() query_statement = mysql_utility.sqlQueryState('daily') cursor.execute(query_statement) conn.commit() result = cursor.fetchall() for memberId in self.allMembers: self.dailyDict[memberId]={} if len(result) > 0: for row in result: if self.dailyDict.has_key(row[0]): date = row[1] daily = dict(zip(self.dailyTabHeader[1:], row[1:])) #daily[self.dailyTabHeader[1]] = date self.dailyDict[row[0]][date] = daily cursor.close() conn.close() return self.dailyDict
def __init__(self,*args): host = unicode(socket.gethostname()).lower() self.depName = '' self.memberId = '' self.memberName = '' self.memberList = set([]) self.projectList = set([]) conn,cursor = self.connectToServer() query_statement = mysql_utility.sqlQueryState(u'user') cursor.execute(query_statement) conn.commit() result = cursor.fetchall() for row in result: if row[3] == host: self.memberId = unicode(row[0]) self.memberName = unicode(row[1]) self.depName = int(row[2]) self.projectDict = {} self.subprojectDict = {} self.taskDict = {} self.allMembers = {} self.proTabHeader = self.getTableHeader(headertable='proTabHeader') self.subproTabHeader = self.getTableHeader(headertable='subproTabHeader') self.taskTabHeader = self.getTableHeader(headertable='taskTabHeader') self.memberTabHeader = self.getTableHeader(headertable='memberTabHeader') self.dailyTabHeader = self.getTableHeader(headertable='dailyTabHeader') self.overtimeTabHeader = self.getTableHeader(headertable='overtimeTabHeader') self.getProjectsFromServer() self.getSubprojectFromServer() self.getTaskFromeServer() self.getMembersFromServer() self.getDailyFromServer() self.buildTreeHierarchy()