def show_bio(username): cur = mysql.connect() cr = cur.cursor() cr.execute("SELECT * FROM dems_biochemic WHERE name LIKE %s",[username]) cv = cr.fetchall() cur.close() return render_template('users/bio1.html',title='bio1',sr = cv)
def show_crdb(username): cur = mysql.connect() cr = cur.cursor() cr.execute("SELECT * FROM home_crdb WHERE name LIKE %s",[username]) cv = cr.fetchall() cur.close() return render_template('users/crdb1.html',title='Crdb1',sr = cv)
def bio(): cur = mysql.connect() cr = cur.cursor() cr.execute("SELECT * FROM dems_biochemic") rows = cr.fetchall() data = [row for row in rows] cur.close() return render_template('users/bio.html',title='Bio', fts=data )
def crdb(): cur = mysql.connect() cr = cur.cursor() cr.execute("SELECT * FROM home_crdb") rows = cr.fetchall() data = [row for row in rows] cur.close() return render_template('users/crdb.html',title='Crdb', fts=data )
def search_bio(): if request.method == 'POST': conn = mysql.connect() cr= conn.cursor() cr.execute("SELECT * FROM dems_biochemic WHERE name LIKE %s",request.form['servs']) conn.close() return render_template("users/bio.html",title='bio_search',ns =cr.fetchall()) return render_template('users/bio.html',title='Bio')
def search_crdb(): if request.method == 'POST': conn = mysql.connect() cr= conn.cursor() cr.execute("SELECT * FROM home_crdb WHERE name LIKE %s",request.form['crdbs']) conn.close() return render_template("users/crdb.html",title='Crdb_search',ns =cr.fetchall()) return render_template('users/crdb.html',title='Crdb')
def get_types_tumor(self): conn = mysql.connect() cursor = conn.cursor() cursor.execute("select * from types_tumor") res_list = cursor.fetchall() cursor.close() conn.close() res_dict = dict() for info in res_list: res_dict[int(info[0])] = info[1] return res_dict
def get_details(self, table_name, image_name): conn = mysql.connect() cursor = conn.cursor() image_path = '' image_name = str(image_name) print image_name if table_name == 'lung_l': image_path = '/static/train_l/' + image_name cursor.execute( "select * from lung_l_details where image_name = '%s'" % image_name) elif table_name == 'lung_m': image_path = '/static/train_m/' + image_name cursor.execute( "select * from lung_m_details where image_name = '%s'" % image_name) res_fetch = cursor.fetchall() res_list = [] res_list.append(image_path) res_list.append(res_fetch) cursor.close() conn.close() return res_list
def search_top(self, coarse_str, fine_str, num, scale): conn = mysql.connect() cursor = conn.cursor() if scale == '400': table_name = 'lung_l' elif scale == '100': table_name = 'lung_m' else: table_name = 'lung_m' cursor.execute("select * from %s where coarse_key = %s" % (table_name, coarse_str)) new_complete_list = list(cursor.fetchall()) if len(new_complete_list) < num: cursor.execute('select id,coarse_key from %s' % table_name) fetch_infos = cursor.fetchall() new_list = [] for len_hanming in xrange(1, 47): if len(new_list) > num - 1: break for info in fetch_infos: if self.hanming(info[1], coarse_str) == len_hanming: new_list.append(info) for info in new_list: cursor.execute("select * from %s where id = %d" % (table_name, info[0])) fetch_info = cursor.fetchall() new_complete_list.append(fetch_info[0]) res_dict = dict() idx = 0 for one_res in new_complete_list: len_res = self.similarity(one_res[2], fine_str) res_dict[idx] = len_res idx += 1 sort_res = sorted(res_dict.items(), key=lambda d: d[1]) if len(new_complete_list) > 0: show_cnt = min(num, len(new_complete_list)) else: show_cnt = 0 files = [] for i in xrange(show_cnt): file_info = [] print sort_res[i][1] file_info.append(new_complete_list[sort_res[i][0]][3]) file_info.append(new_complete_list[sort_res[i][0]][4]) files.append(file_info) cursor.close() conn.close() return files else: res_dict = dict() idx = 0 for one_res in new_complete_list: len_res = self.similarity(one_res[2], fine_str) res_dict[idx] = len_res idx += 1 sort_res = sorted(res_dict.items(), key=lambda d: d[1]) if len(new_complete_list) > 0: show_cnt = min(num, len(new_complete_list)) else: show_cnt = 0 files = [] for i in xrange(show_cnt): file_info = [] print sort_res[i][1] file_info.append(new_complete_list[sort_res[i][0]][3]) file_info.append(new_complete_list[sort_res[i][0]][4]) files.append(file_info) cursor.close() conn.close() return files