def change_status(task_id): print("The task_id is " + str(task_id)) status = Task.get(str(task_id)).get_status() if status == "Open": sql = text('update task set status="Closed" where task.task_id="' + str(task_id) + '"') result = engine.execute(sql) else: sql = text('update task set status="Open" where task.task_id="' + str(task_id) + '"') result = engine.execute(sql)
def test(season, episode): cs = engine.execute(''' select c.CID, name, actor, season_of_death, episode_of_death, means_of_death, episodeCount, CASE WHEN cast(season_of_death as integer) == {} and cast(episode_of_death as integer) == {} THEN cast(0 as bit) ELSE cast(1 as bit) END as isAlive from characters as c, episodes as e, episode_characters as ec, (select c1.CID, count(*) as episodeCount from episodes as e1, characters as c1, episode_characters as ec1 where ((cast(e1.seasonNumber as integer) < {}) or (cast(e1.seasonNumber as integer) == {} and cast(e1.episodeNumber as integer) <= {})) and e1.EID == ec1.EID and c1.CID == ec1.CID group by c1.CID ) as eCounts where cast(seasonNumber as integer) == {} and cast(episodeNumber as integer) == {} and e.EID == ec.EID and c.CID == ec.CID and c.CID == eCounts.CID ; '''.format(season, episode, season, season, episode, season, episode)) characters = [] for character in cs: character_dict = {} for pair in character.items(): character_dict[pair[0]] = pair[1] characters.append(character_dict) return jsonify(characters), 200
def get_table_data(db: Session, name: str): my_table = Table(name, metadata, autoload=True, autoload_with=db) s = select([my_table]) result = engine.execute(s) temp = [] for row in result: temp.append(row) return temp
def get_permission(user_id, project_id): sql = text ('select pp.group \ from project_permission pp \ where pp.user_id ="' + str(user_id) \ + '" and pp.project_id ="' + str(project_id) + '"') result = engine.execute(sql) group = None for row in result: group = row[0] return group
def get_projects(user, group): sql = text('select distinct p.name, p.project_id, pp.group ' + \ 'from project p, user u, project_permission pp ' + \ 'where p.project_id=pp.project_id and pp.user_id=' + \ str(user.get_id()) + ' and pp.group="' + group + '"') result = engine.execute(sql) print ("result: ", result) projects = { "name": [], "id": [] } for row in result: projects["name"].append(row[0]) projects["id"].append(row[1]) print ("Project: ", row[0],'\t',row[1]) return projects
def get_collaborators(project_id): sql = text ('select user_id from project_permission where project_permission.project_id=' + str(project_id)) return engine.execute(sql)
def del_user(user_id, project_id): sql = text ('delete from project_permission where user_id=' + str(user_id) + ' and ' \ 'project_id="' + str(project_id) + '"') result = engine.execute(sql)
def get_completed_tasks(project_id): sql = text('select task_id, description from task where task.project_id=' + str(project_id) + ' and task.status="Closed"') result = engine.execute(sql) return result
def get_active_tasks(project_id): sql = text('select task_id, description from task where task.project_id=' + str(project_id) + ' and task.status="Open"') result = engine.execute(sql) return result
def get_times(task_id): sql = text('select start_time, end_time from time_entry where time_entry.task_id="' + str(task_id) + '"') result = engine.execute(sql) return result
def get_entries(id): sql = text('select time_entry_id, user_id, start_time, end_time \ from time_entry where time_entry.task_id ="' + str(id)+ '"') return engine.execute(sql)