def addNode(nodeName,fNodeId): conn = Db.getConn() cursor = conn.cursor() # 获取id cursor.execute('select MAX(id) as id from t_catalog ') row = cursor.fetchone() newId = row[0] if newId == None: newId = 500 newId = newId +1 # print(newId) # 计算最大序号 cursor.execute('select MAX(serNo) as serNo from t_catalog where fnodeId=%s', (fNodeId,)) row = cursor.fetchone() serNo = row[0] if serNo == None: serNo = 0 serNo = serNo +1 # 插入记录 cursor.execute('insert into t_catalog (id,fnodeId,nodeName,serNo) values (%s,%s, %s,%s)', (newId,fNodeId, nodeName,serNo)) conn.commit() cursor.close() return newId
def getTaskListByDate(searchDate): conn = Db.getConn() cursor = conn.cursor() # 获取id cursor.execute('select id,taskName,status from t_task where date=%s',(searchDate,)) rows = cursor.fetchall() outList =[] for row in rows: #print(row) task = Task() task.id = row[0] task.taskName = row[1] task.status = row[2] outList.append(task) cursor.close() conn.close() return outList