def getinfo(i):
    m_d = Database()
    sql = "SELECT * from song_list " \
          "where song_list.ID = '%d'" % i
    m_d.cursor.execute(sql)
    data = m_d.cursor.fetchall()
    return data
 def search_lyric(search_word):
     m_d = Database()
     sql = "SELECT * FROM lyric_inverted_index WHERE lyric_inverted_index.word='%s'" % search_word
     m_d.cursor.execute(sql)
     # 获取所有记录列表
     data = m_d.cursor.fetchall()
     return data
 def get_physics(the_id):
     m_d = Database()
     sql = "SELECT * from Wxy" \
           " WHERE id = %d" % the_id
     m_d.cursor.execute(sql)
     data = m_d.cursor.fetchall()
     m_d.db.close()
     return data
Пример #4
0
 def search_name(search_word):
     m_d = Database()
     sql = "SELECT * FROM name_inverted_index WHERE name_inverted_index.word='%s'" % search_word
     m_d.cursor.execute(sql)
     # 获取所有记录列表
     data = m_d.cursor.fetchall()
     if data == ():
         return []
     return convert_list(data[0][2])
 def get_search_list(id_list):
     print(id_list[0])
     m_d = Database()
     id_str = str(id_list[0])
     for val in id_list[1:]:
         id_str += ',' + str(val)
     sql = "SELECT * from song_list WHERE id in (%s)" % id_str
     m_d.cursor.execute(sql)
     data = m_d.cursor.fetchall()
     return data
Пример #6
0
 def get_vector_list(kind=0):
     m_d = Database()
     if kind == 0:
         sql = "SELECT * from lyric_vector_index " \
               "INNER JOIN song_list " \
               "on song_list.ID = lyric_vector_index.Sid limit 10"
     else:
         sql = "SELECT * from name_vector_index " \
               "INNER JOIN song_list " \
               "on song_list.ID = name_vector_index.Sid limit 10"
     m_d.cursor.execute(sql)
     data = m_d.cursor.fetchall()
     return data
Пример #7
0
 def get_word_num(search_word, kind=0):
     m_d = Database()
     if kind == 0:
         sql = "SELECT * FROM lyric_inverted_index " \
               "WHERE lyric_inverted_index.word='%s'" \
               % search_word
     else:
         sql = "SELECT * FROM name_inverted_index " \
               "WHERE name_inverted_index.word='%s'" \
               % search_word
     m_d.cursor.execute(sql)
     # 获取所有记录列表
     data = m_d.cursor.fetchall()
     if data == ():
         return 0
     return data[0][3]
Пример #8
0
 def __init__(self, sid, kind=0):
     self.id = sid
     self.kind = kind
     m_d = Database()
     if kind == 0:
         sql = "SELECT * from lyric_vector_index where sid = %d" % int(sid)
     else:
         sql = "SELECT * from name_vector_index where sid = %d" % int(sid)
     m_d.cursor.execute(sql)
     data = m_d.cursor.fetchall()
     if not data == ():
         self.w_list = get_weight_list(data[0][1])
         self.length = data[0][2]
     else:
         self.w_list = Counter()
         self.length = 0
Пример #9
0
 def get_word_info(search_word, kind=0):
     m_d = Database()
     if kind == 0:
         sql = "SELECT * FROM lyric_inverted_index " \
               "WHERE lyric_inverted_index.word='%s'" \
               % search_word
     else:
         sql = "SELECT * FROM name_inverted_index " \
               "WHERE name_inverted_index.word='%s'" \
               % search_word
     m_d.cursor.execute(sql)
     # 获取所有记录列表
     data = m_d.cursor.fetchall()
     if data == ():
         return {'list': [], 'num': 0, 'id': -1}
     return {
         'list': convert_list(data[0][2]),
         'num': data[0][3],
         'id': data[0][0]
     }
Пример #10
0
 def name_inverted_index_list():
     m_d = Database()
     m_d.cursor.execute("SELECT * from name_inverted_index limit 100")
     data = m_d.cursor.fetchall()
     return data
Пример #11
0
 def get_one_song(id):
     m_d = Database()
     sql = "SELECT * from song_list WHERE id = '%s'" % id
     m_d.cursor.execute(sql)
     data = m_d.cursor.fetchall()
     return data[0]
Пример #12
0
def maxid():
    m_d = Database()
    sql = "SELECT MAX(ID) from song_list"
    m_d.cursor.execute(sql)
    data = m_d.cursor.fetchall()
    return data[0][0]
Пример #13
0
 def song_name_list():
     m_d = Database()
     m_d.cursor.execute("SELECT song_id,song_name,id from song_list")
     data = m_d.cursor.fetchall()
     return data
Пример #14
0
 def song_number():
     m_d = Database()
     m_d.cursor.execute("SELECT COUNT(ID) from song_list")
     data = m_d.cursor.fetchall()
     m_d.db.close()
     return data[0][0]