def get_videos(video): check_input_manager('video', video, ['username']) #query = "SELECT * FROM video WHERE username='******'" % (video['username']) query = "SELECT * FROM (SELECT video.*, COUNT(DISTINCT annotation.entity_id) AS entity_num FROM video \ LEFT OUTER JOIN annotation ON video.video_id=annotation.video_id AND video.username='******' GROUP BY video.video_id) \ AS v WHERE v.status!='deleted'" % (video['username']) print("Videos from user %s are fetched!" % video['username']) return run_all_query(query)
def get_categoris(sup_cat=None): query = "SELECT * FROM category" if sup_cat is not None: query += " WHERE sup_cat_name='%s'" % sup_cat print("categories are fetched!") return run_all_query(query)
def get_annotations(anno): if 'annotation_id' in anno: query = "SELECT * FROM annotation WHERE annotation_id='%s'" % ( anno['annotation_id']) print("annotation_id %s is fetched!" % anno['annotation_id']) else: check_input_manager('annotation', anno, ['video_id']) query = "SELECT * FROM annotation WHERE video_id='%s'" % ( anno['video_id']) if 'job_id' in anno: query += " AND job_id='%s'" % anno['job_id'] if 'username' in anno: query += " AND username='******'" % anno['username'] if 'entity_id' in anno: query += " AND entity_id='%s'" % anno['entity_id'] if 'frame_num' in anno: query += " AND frame_num='%s'" % anno['frame_num'] if 'cat_id' in anno: query += "AND cat_id='%s'" % anno['cat_id'] print("annotations from video %s are fetched!" % anno['video_id']) return run_all_query(query)
def get_server(server): check_input_manager('server', server, ['server_id']) query = "SELECT * FROM function WHERE server_id='%s'" % \ (server['server_id']) print("server %s is fetched!" % server['server_id']) return run_all_query(query)
def get_entity(entity_id): query = "SELECT * FROM entity WHERE entity_id='%s'" % entity_id print("entity is fetched!" % entity_id) return run_all_query(query)
def get_entities(video_id): query = "SELECT * FROM entity WHERE video_id='%s'" % video_id print("entities in video %s are fetched!" % video_id) return run_all_query(query)
def get_video(video): check_input_manager('video', video, ['video_id']) query = "SELECT * FROM video WHERE status != 'deleted' AND video_id='%s'" % ( video['video_id']) print("Video %s is fetched!" % video['video_id']) return run_all_query(query)
def get_category(cat_id): query = "SELECT * FROM category WHERE cat_id='%s'" % cat_id print("cat_id %s is fetched!" % cat_id) return run_all_query(query)
def get_job(job): check_input_manager('job', job, ['job_id']) query = "SELECT * FROM job WHERE job_id='%s'" % \ (str(job['job_id'])) print("Job %s is fetched!" % job['job_id']) return run_all_query(query)
def get_jobs(job): check_input_manager('job', job, ['video_id']) query = "SELECT * FROM job WHERE video_id='%s'" % (str(job['video_id'])) print("Jobs from user %s are fetched!" % job['video_id']) return run_all_query(query)
def get_user(user): check_input_manager('user', user, ['username']) query = "SELECT * FROM user WHERE username='******'" % user['username'] print("User %s is fetched!" % user['username']) return run_all_query(query)