def export_hists():
    """
    export all history data
    """
    print log.hl(msg.history_exporting ,'cyan')
    conn = __getConnection()
    dao = HistDao(conn)
    hists = dao.get_all_histories()

    filename = path.join(config.DOWNLOAD_DIR,'zhuaxia_history_'+str(datetime.datetime.today())+".csv")

    with codecs.open(filename, 'w', 'utf-8') as f:
        f.write( "id;song_id;song_name;quality;source;location;api_url;download_time;download_times\n")
        for h in hists:
            f.write(h.to_csv())
            f.write("\n")

    print log.hl(msg.history_exported % filename ,'cyan')
    conn.close()
dataset/ETHPy150Open sk1418/zhuaxia/zhuaxia/hist_handler.py/export_hists/original