def migrate_lbryfile_manager_db(old_db_dir, new_db_dir):
    old_db_path = os.path.join(old_db_dir, "lbryfiles.db")
    if not os.path.exists(old_db_path):
        return True
    old_db = leveldb.LevelDB(old_db_path)
    new_db = sqlite3.connect(os.path.join(new_db_dir, "lbryfile_info.db"))
    c = new_db.cursor()
    c.execute("create table if not exists lbry_file_options (" +
              "    blob_data_rate real, " +
              "    status text," +
              "    stream_hash text,"
              "    foreign key(stream_hash) references lbry_files(stream_hash)" +
              ")")
    new_db.commit()
    LBRYFILE_STATUS = "t"
    LBRYFILE_OPTIONS = "o"
    c = new_db.cursor()
    for k, v in old_db.RangeIter():
        key_type, stream_hash = json.loads(k)
        if key_type == LBRYFILE_STATUS:
            try:
                rate = json.loads(old_db.Get(json.dumps((LBRYFILE_OPTIONS, stream_hash))))[0]
            except __HOLE__:
                rate = None
            c.execute("insert into lbry_file_options values (?, ?, ?)",
                      (rate, v, stream_hash))
    new_db.commit()
    new_db.close()
dataset/ETHPy150Open lbryio/lbry/lbrynet/db_migrator/migrate0to1.py/migrate_lbryfile_manager_db