|
楼主 |
发表于 2020-1-26 16:05:53
|
显示全部楼层
本帖最后由 foolenough 于 2020-1-26 04:13 PM 编辑
附上本次修改相应素材和脚本
- #! /bin/python
- import sqlite3
- #conn = sqlite3.connect('pkuxkx_p2palias_v2016.db')
- conn = sqlite3.connect("pkuxkx_p2palias_v2019_1020.db")
- cursor = conn.cursor()
- # return nodeno by nodeid
- def get_nodeno(nodeid):
- cursor.execute('select nodeno from mud_node where nodeid="%s"' % nodeid)
- nodeno = cursor.fetchone()
- if nodeno is None:
- print(nodeid)
- return nodeno
- return nodeno[0]
- lz = [
- "lanzhou,hhbeigudu,walk lingzhou",
- "hhbeigudu,lanzhou,walk lanzhou",
- "lanzhou,huangzhong",
- "huangzhong,xingxiu"
- ]
- bj = [
- "puyang,huanghebeidukou3,walk qufu",
- "huanghebeidukou3,puyang,walk puyang",
- "puyang,beijing",
- "beijing,andingmen,walk anding",
- "andingmen,beijing,walk yongan",
- "beijing,deshengmen,walk desheng",
- "deshengmen,beijing,walk yongan",
- "beijing,guanganmen,walk guangan",
- "andingmen,beijing,walk yongan",
- "andingmen,guanwailaolongtou,walk guanwai",
- "guanwailaolongtou,andingmen,walk beijing",
- "andingmen,deshengmen,walk desheng",
- "deshengmen,andingmen,walk anding",
- "andingmen,guanganmen,walk guangan",
- "guanganmen,andingmen,walk anding",
- "deshengmen,guanganmen,walk guangan",
- "guanganmen,deshengmen,walk desheng",
- "deshengmen,zhangjiakou,walk zhangjiakou",
- "zhangjiakou,deshengmen,walk beijing",
- "zhangjiakou,menggutulu,walk menggu",
- "menggutulu,zhangjiakou,walk zhangjiakou",
- "zhangjiakou,jinyangguangchang,walk jinyang",
- "jinyangguangchang,zhangjiakou,walk zhangjiakou",
- "jinyangguangchang,fenglingdu,walk luoyang",
- "fenglingdu,jinyangguangchang,walk jinyang",
- "jinyangguangchang,riyue,walk riyue",
- "riyue,jinyangguangchang,walk jinyang",
- "jinyangguangchang,guanganmen,walk beijing",
- "guanganmen,jinyangguangchang,walk jinyang",
- "riyue,guanganmen,walk beijing",
- "guanganmen,riyue,walk riyue",
- ]
- yz= [
- "yangzhou,yangzijin,walk zhenjiang",
- "yangzijin,yangzhou,walk yangzhou",
- "yangzhou,changjiangbeidukou1,walk jiankang",
- "changjiangbeidukou1,yangzhou,walk yangzhou",
- "yangzhou,qufugulou,walk qufu",
- "qufugulou,yangzhou,walk yangzhou",
- "yangzhou,gaibang",
- "yangzhou,xinyang",
- "qufugulou,taishandaizongfang,walk taishan",
- "taishandaizongfang,qufugulou,walk qufu",
- "qufugulou,huanghenandukou1,walk puyang",
- "huanghenandukou1,qufugulou,walk qufu",
- "qufugulou,huaibei,walk huaibei",
- "huaibei,qufugulou,walk qufu",
- "huaibei,xuchang",
- "nanyang,xuchang",
- "ruzhou,xuchang",
- "xinyang,xuchang",
- "xinyang,cjbeidukou2,walk jiangzhou",
- "cjbeidukou2,xinyang,walk xinyang",
- "xinyang,xiangyang",
- "xinyang,shashouguangchang,walk shashou",
- "shashouguangchang,xinyang,walk xinyang",
- "xiangyang,nanyang",
- "xiangyang,wudangshanmen,walk wudang",
- "wudangshanmen,xiangyang,walk xiangyang",
- "xiangyang,jingzhou",
- "jingzhou,lingji,walk yueyang",
- "lingji,jingzhou,walk jingzhou",
- "nanyang,luoyang",
- "nanyang,xiaocun,walk huashancun",
- "xiaocun,nanyang,walk nanyang",
- "xiaocun,quanzhengongmen,walk quanzhen",
- "quanzhengongmen,xiaocun,walk huashancun",
- "quanzhengongmen,gumu,walk gumu",
- "gumu,quanzhengongmen,walk quanzhen",
- "xiaocun,huashanqianchichuang,walk huashan",
- "huashanqianchichuang,xiaocun,walk huashancun",
- "luoyang,mengjindu,walk jinyang",
- "mengjindu,luoyang,walk luoyang",
- "luoyang,ruzhou",
- "ruzhou,2xu,walk shaolin",
- "2xu,ruzhou,walk ruzhou",
- "luoyang,qilincun",
- "luoyang,changantonghuamen,walk changan",
- "changantonghuamen,luoyang,walk luoyang",
- "changantonghuamen,changanjinguangmen,walk jinguang",
- "changanjinguangmen,changantonghuamen,walk tonghua",
- "changantonghuamen,changanmingdemen,walk mingde",
- "changanmingdemen,changantonghuamen,walk tonghua",
- "changanjinguangmen,changanmingdemen,walk mingde",
- "changanmingdemen,changanjinguangmen,walk jinguang",
- "huizuxiaozhen,lingjiu,walk lingjiu",
- "lingjiu,huizuxiaozhen,walk huijiang",
- "huizuxiaozhen,lingzhou,walk lingzhou",
- "lingzhou,huizuxiaozhen,walk huijiang",
- "lingzhou,hhnangudu,walk lanzhou",
- "hhnangudu,lingzhou,walk lingzhou",
- "zanpu,dalunsishanmen,walk dalunsi",
- "dalunsishanmen,zanpu,walk zanpu",
- "chengdu,emeishanmen,walk emei",
- "emeishanmen,chengdu,walk chengdu",
- "dali,kunming",
- "kunming,pingxiwang,walk pingxi",
- "pingxiwang,kunming,walk kunming",
- "miaoling,nanchang,walk nanchang",
- "nanchang,miaoling,walk miaojiang",
- "miaoling,yueyang,walk yueyang",
- "yueyang,miaoling,walk miaojiang",
- "jiangzhou,nanchang",
- "jiangzhou,cjnandukou2,walk xinyang",
- "cjnandukou2,jiangzhou,walk jiangzhou",
- "jiangzhou,yueyang",
- "jiangzhou,jiankangqingliangmen,walk jiankang",
- "jiankangqingliangmen,jiangzhou,walk jiangzhou",
- "jiankangqingliangmen,jiankangzhengyangmen,walk zhengyang",
- "jiankangzhengyangmen,jiankangqingliangmen,walk qingliang",
- "jiankangqingliangmen,jiankangshencemen,walk shence",
- "jiankangshencemen,jiankangqingliangmen,walk qingliang",
- "jiankangqingliangmen,jiankangchaoyangmen,walk chaoyang",
- "jiankangchaoyangmen,jiankangqingliangmen,walk qingliang",
- "jiankangchaoyangmen,jiankangzhengyangmen,walk zhengyang",
- "jiankangzhengyangmen,jiankangchaoyangmen,walk chaoyang",
- "jiankangchaoyangmen,jiankangshencemen,walk shence",
- "jiankangshencemen,jiankangchaoyangmen,walk chaoyang",
- "jiankangzhengyangmen,jiankangshencemen,walk shence",
- "jiankangshencemen,jiankangzhengyangmen,walk zhengyang",
- "jiankangshencemen,changjiangnanyanziji,walk yanziji",
- "changjiangnanyanziji,jiankangshencemen,walk jiankang",
- "nanchang,quanzhou",
- "quanzhou,jiaxing",
- "quanzhou,fuzhou",
- "quanzhou,putian",
- "quanzhou,hangzhou,walk linan",
- "hangzhou,quanzhou,walk quanzhou",
- "hangzhou,jiankangzhengyangmen,walk jiankang",
- "jiankangzhengyangmen,hangzhou,walk linan",
- "hangzhou,gushanmeizhuang,walk meizhuang",
- "gushanmeizhuang,hangzhou,walk linan",
- "hangzhou,yuefeimu,walk yuewangmu",
- "yuefeimu,hangzhou,walk linan",
- "putian,fuzhou",
- "fuzhou,jiaxing",
- "jiaxing,lujiazhuang",
- "jiaxing,suzhoucanglangting,walk suzhou",
- "suzhoucanglangting,jiaxing,walk jiaxing",
- "jiaxing,yuefeimu,walk yuewangmu",
- "yuefeimu,jiaxing,walk jiaxing",
- "jiaxing,jiaxingtaihubian1,walk murong",
- "jiaxingtaihubian1,jiaxing,walk jiaxing",
- "jiaxing,mingzhouqingyuangang,walk mingzhou",
- "mingzhouqingyuangang,jiaxing,walk jiaxing",
- "jiaxing,yashan",
- "jiaxing,jiankangzhengyangmen,walk jiankang",
- "jiankangzhengyangmen,jiaxing,walk jiaxing",
- "suzhoucanglangting,guiyunzhuang,walk guiyun",
- "guiyunzhuang,suzhoucanglangting,walk suzhou",
- "suzhoucanglangting,murong,walk murong",
- "murong,suzhoucanglangting,walk suzhou",
- "guiyunzhuang,murong,walk murong",
- "murong,guiyunzhuang,walk guiyun",
- "suzhoucanglangting,yixingxiancheng,walk yixing",
- "yixingxiancheng,suzhoucanglangting,walk suzhou",
- "suzhoucanglangting,jiankangchaoyangmen,walk jiankang",
- "jiankangchaoyangmen,suzhoucanglangting,walk suzhou",
- ]
- def prepare(ps):
- results = []
- for ori in ps:
- sections = str.split(ori, ",")
- if len(sections) == 2:
- nodeno = get_nodeno(sections[0])
- linknodeno = get_nodeno(sections[1])
- results.append({"nodeno":nodeno, "linknodeno":linknodeno, "path": "walk %s" % sections[1], "linknodeid":sections[1]})
- results.append({"nodeno":linknodeno, "linknodeno":nodeno, "path": "walk %s" % sections[0], "linknodeid":sections[0]})
- elif len(sections) == 3:
- nodeno = get_nodeno(sections[0])
- linknodeno = get_nodeno(sections[1])
- results.append({"nodeno":nodeno, "linknodeno":linknodeno, "path": sections[2], "linknodeid":sections[1]})
- return results
- def sql_prepare(results):
- for res in results:
- statement = 'insert into mud_links(nodeno, linknodeno, path, linknodeid) values (%d,%d,"%s","%s");' % (res["nodeno"], res["linknodeno"], res["path"], res["linknodeid"])
- print(statement)
- sql_prepare(prepare(yz))
- sql_prepare(prepare(lz))
- sql_prepare(prepare(bj))
复制代码 |
|