Short example of how to access the replica databases from PAWS.

import pymysql  # We will use pymysql to connect to the database
import os

Credententials for the MySQL database, along with the name of the host to connect to, are passed in via environment variables. Note that there's a 30minute limit on the query execution times.

host = os.environ['MYSQL_HOST']
user = os.environ['MYSQL_USERNAME']
password = os.environ['MYSQL_PASSWORD']
conn = pymysql.connect(

The database names are 'dbname of wiki' followed by '_p'. So English Wikipedia is enwiki_p, commons is commonswiki_p, meta is metawiki_p, wikidata is wikidatawiki_p, Tamil Wikisource is tawikisource_p, etc. You can see the database schema here

with conn.cursor() as cur:
    cur.execute('use enwiki_p')
        SELECT *
        FROM revision JOIN page 
            ON page.page_id = revision.rev_page
        WHERE page.page_namespace = 0 AND page.page_title = 'India' 
        ORDER BY revision.rev_timestamp DESC
        LIMIT 1
((740776952, 14533, 0, b'/* Society */ rm content added wihtout consensus after it was removed for that reason', 9661331, b'SpacemanSpiff', b'20160923062110', 0, 0, 185357, 740746296, b'b1crpqhvpb23gvmrgdhhnx94c1x1v2w', None, None, 14533, 0, b'India', b'', 6994, 0, 0, 0.245421638940854, b'20160924113133', b'20160924110501', 740776952, 185357, b'wikitext'),)