示例#1
0
class quick(object):
    def __init__(self, table, mode, data, d_path):
        self.table = table  # 表名
        self.mode = mode  # 建字段
        self.data = data  # 插入数据SQL语句
        self.db = Create_db(self.table, self.mode, self.data, d_path)

    def new_db(self):
        self.db.new_sql()

    def new_index(self, s_path):
        # 插入数据
        t = time.time()
        try:
            for root, file_p, filename in os.walk(s_path):
                if filename and root:
                    for name in filename:
                        self.db.add_sql(_control(root, name))
                        # self.file_li.append(name)
            self.db.com_clone()
        except OSError:
            # 因为文件访问权限问题,不可能所有都能搜索,因此忽略掉这部分
            pass
        t2 = time.time()
        print(t2 - t)

    @staticmethod
    def search():
        return r_db_file().r_list()  # 返回得到到的文件列表
示例#2
0
def get_data(url):
    try:
        Create_db(db_table, db_mode, db_sql, db_name).new_sql()
    except:
        pass

    db = Create_db(db_table, db_mode, db_sql, db_name)
    for singer_index, index_id in zip(
            GETNameID(url).song_name(),
            GETNameID(url).song_id()):
        data_dict = {"singer_name": singer_index, "singer_id": index_id}
        db.add_sql(data_dict)
    db.com_clone()
示例#3
0
def get_singer_song(name):
    # 歌手全名
    db_mode_singer = f"""
        create table {name} (
            [id] integer PRIMARY KEY AUTOINCREMENT,
            song_name text,
            song_id text
        )
    """
    db_sql_singer = f"""
        insert into {name} (song_name, song_id) 
        values (:song_name, :song_id)
    """
    try:
        Create_db(name, db_mode_singer, db_sql_singer, cache_db).new_sql()
    except:
        pass
    m = Create_db(name, db_mode_singer, db_sql_singer, cache_db)
    id_id = vague_search(name)
    for id, song in zip(
            GETIndex(f'{song_index}{id_id}').song_id(),
            GETIndex(f'{song_index}{id_id}').song_name()):
        m.add_sql({"song_name": song, "song_id": id})
    m.com_clone()