Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
This query is marked as a draft
This query has been published
by
TheImaCow
.
Toggle Highlighting
SQL
import datetime; import MySQLdb; import wikitools; import settings; report_title = settings.rootpage + 'Articles containing linked e-mail addresses' report_template = u''' Articles containing linked e-mail addresses; data as of <onlyinclude>%s</onlyinclude>. {| class="wikitable sortable plainlinks" style="width:100%%; margin:auto;" |- style="white-space:nowrap;" ! No. ! Page |- %s |} ''' wiki = wikitools.Wiki(settings.apiurl) wiki.login(settings.username, settings.password) conn = MySQLdb.connect(host=settings.host, db=settings.dbname, read_default_file='~/.my.cnf') cursor = conn.cursor() cursor.execute(''' /* linkedemailsinarticles.py SLOW_OK */ SELECT DISTINCT page_title FROM externallinks JOIN page ON el_from = page_id WHERE el_to LIKE 'mailto:%' AND page_namespace = 0 LIMIT 1000; ''') i = 1 output = [] for row in cursor.fetchall(): page_title = u'[[%s]]' % unicode(row[0], 'utf-8') table_row = u'''| %d | %s |-''' % (i, page_title) output.append(table_row) i += 1 cursor.execute('SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(rc_timestamp) FROM recentchanges ORDER BY rc_timestamp DESC LIMIT 1;') rep_lag = cursor.fetchone()[0] current_of = (datetime.datetime.utcnow() - datetime.timedelta(seconds=rep_lag)).strftime('%H:%M, %d %B %Y (UTC)') report = wikitools.Page(wiki, report_title) report_text = report_template % (current_of, '\n'.join(output)) report_text = report_text.encode('utf-8') report.edit(report_text, summary=settings.editsumm, bot=1) cursor.close() conn.close()
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...