Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $ jsub -N updateTest python update.py # I do not have the exact job ID right now
- Your job JOBIDREDACTED ("updateTest") has been submitted
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $ cat ~/updateTest.*
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $ ls
- core getdata.sql update.py wmflabs
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $ gdb
- GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
- Copyright (C) 2014 Free Software Foundation, Inc.
- License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
- This is free software: you are free to change and redistribute it.
- There is NO WARRANTY, to the extent permitted by law. Type "show copying"
- and "show warranty" for details.
- This GDB was configured as "x86_64-linux-gnu".
- Type "show configuration" for configuration details.
- For bug reporting instructions, please see:
- <http://www.gnu.org/software/gdb/bugs/>.
- Find the GDB manual and other documentation resources online at:
- <http://www.gnu.org/software/gdb/documentation/>.
- For help, type "help".
- Type "apropos word" to search for commands related to "word".
- (gdb) core core
- [New LWP 10475]
- Core was generated by `/usr/bin/python2.7 update.py'.
- Program terminated with signal SIGSEGV, Segmentation fault.
- #0 0x000000000051519c in ?? ()
- (gdb) quit
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $ cat update.py
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- from wmflabs import db
- # Get the data from database
- conn = db.connect('cswiki')
- with conn.cursor() as cur:
- sql = "SELECT pl_namespace AS namespace, pl_title AS title, COUNT(*) AS value FROM pagelinks LEFT JOIN page AS pg1 ON pl_namespace = pg1.page_namespace AND pl_title = pg1.page_title LEFT JOIN page AS pg2 ON pl_from = pg2.page_id WHERE pg1.page_namespace IS NULL AND pl_namespace NOT IN ( 2, 3 ) AND pg2.page_namespace NOT IN ( 8, 10 ) GROUP BY pl_namespace, pl_title ORDER BY value;"
- cur.execute(sql)
- data = cur.fetchall()
- # Store the data into tools-db
- conn = db.connect('s53348__mostLinkedMissing')
- with conn.cursor() as cur:
- sql = 'drop table if exists mostLinkedMissingNew;'
- cur.execute(sql)
- with conn.cursor() as cur:
- sql = 'create table mostLinkedMissingNew ( namespace int , title varchar(256) , value int );'
- cur.execute(sql)
- for row in data:
- with conn.cursor() as cur:
- sql = 'insert into mostLinkedMissingNew(namespace, title, value) values(' + str(row[0]) + ', "' + row[1] + '", ' + str(row[2]) + ');'
- cur.execute(sql)
- tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
- $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement