#include "MySQLWrapper.h" #include #include #include #include #include #include #include #include #include #include using namespace std; #include "local_db_account.h" #include "util.hpp" int main() { /// 3.4 企业对哪类大数据人才需求最为迫切 MySQLConn conn; conn.connect("127.0.0.1",db_user,db_passwd,"bigdata3",3306); cout<<"Connected to DB"< mp; conn.exec("select title,count(*) from lagou_job where ((title like '%大数据%') or (tags like '%大数据%')) group by title",[&](MySQLResult& res) { res.stepRow([&](char** val,unsigned long* len) { string title(val[0]); mp[Trim(title)]=ParseInt(val[1]); }); }); conn.exec("use bigdata5",nullptr); conn.exec("select title,count(*) from pages where ((title like '%大数据%') or (tags like '%大数据%')) group by title",[&](MySQLResult& res) { res.stepRow([&](char** val,unsigned long* len) { string title(val[0]); auto iter=mp.find(Trim(title)); if(iter!=mp.end()) { iter->second += ParseInt(val[1]); } else { mp.insert(make_pair(Trim(title),ParseInt(val[1]))); } }); }); vector> vec; for(const auto& pr:mp) { vec.push_back(pr); } sort(vec.begin(),vec.end(),[&](const pair& a,const pair& b) { return a.second > b.second; }); ofstream ofs("result/3.4.csv"); #define cout ofs int szVec=vec.size(); int maxLoop=min(szVec,10); for(int i=0;i