Advertisement
Urbanecm

Untitled

Dec 16th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  2. $ jsub -N updateTest python update.py # I do not have the exact job ID right now
  3. Your job JOBIDREDACTED ("updateTest") has been submitted
  4. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  5. $ cat ~/updateTest.*
  6. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  7. $ ls
  8. core getdata.sql update.py wmflabs
  9. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  10. $ gdb
  11. GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
  12. Copyright (C) 2014 Free Software Foundation, Inc.
  13. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  14. This is free software: you are free to change and redistribute it.
  15. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
  16. and "show warranty" for details.
  17. This GDB was configured as "x86_64-linux-gnu".
  18. Type "show configuration" for configuration details.
  19. For bug reporting instructions, please see:
  20. <http://www.gnu.org/software/gdb/bugs/>.
  21. Find the GDB manual and other documentation resources online at:
  22. <http://www.gnu.org/software/gdb/documentation/>.
  23. For help, type "help".
  24. Type "apropos word" to search for commands related to "word".
  25. (gdb) core core
  26. [New LWP 10475]
  27. Core was generated by `/usr/bin/python2.7 update.py'.
  28. Program terminated with signal SIGSEGV, Segmentation fault.
  29. #0 0x000000000051519c in ?? ()
  30. (gdb) quit
  31. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  32. $ cat update.py
  33. #!/usr/bin/env python
  34. #-*- coding: utf-8 -*-
  35.  
  36. from wmflabs import db
  37.  
  38. # Get the data from database
  39. conn = db.connect('cswiki')
  40. with conn.cursor() as cur:
  41. 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;"
  42. cur.execute(sql)
  43. data = cur.fetchall()
  44.  
  45.  
  46. # Store the data into tools-db
  47. conn = db.connect('s53348__mostLinkedMissing')
  48. with conn.cursor() as cur:
  49. sql = 'drop table if exists mostLinkedMissingNew;'
  50. cur.execute(sql)
  51.  
  52. with conn.cursor() as cur:
  53. sql = 'create table mostLinkedMissingNew ( namespace int , title varchar(256) , value int );'
  54. cur.execute(sql)
  55.  
  56. for row in data:
  57. with conn.cursor() as cur:
  58. sql = 'insert into mostLinkedMissingNew(namespace, title, value) values(' + str(row[0]) + ', "' + row[1] + '", ' + str(row[2]) + ');'
  59. cur.execute(sql)
  60. tools.mostlinkedmissing@tools-bastion-03 ~/mostlinkedmissing/generator
  61. $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement