import os
import pymysql
conn = pymysql.connect(
    host=os.environ['MYSQL_HOST'],
    user=os.environ['MYSQL_USERNAME'],
    password=os.environ['MYSQL_PASSWORD'],
    database='enwiki_p',
    charset='utf8'
)
with conn.cursor() as cur:
    cur.execute('use enwiki_p')
    cur.execute("select CONCAT('# [[:Category:',cat_title,']]') AS cat_title from category LEFT JOIN page p2 \
ON cat_title = p2.page_title AND p2.page_namespace = 14 LEFT JOIN page_props ON p2.page_id = pp_page \
WHERE pp_propname not like 'hiddencat' and cat_pages = 0 order by cat_title")
    print(cur.fetchall())
IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.

Current values:
NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)
NotebookApp.rate_limit_window=3.0 (secs)