Mediawiki-utilities/mwdb

This library provides a set of utilities for connecting to and querying a MediaWiki database.

The [//pythonhosted.org/mwdb/schema.html#mwdb.Schema mwdb.Schema] object is a thin wrapper around an sqlalchemy Engine and MetaData that adapts to the local database setup. When using a [//pythonhosted.org/mwdb/schema.html#mwdb.Schema mwdb.Schema] member table ORM, the internal mapping will translate between public replicas views (e.g. revision_userindex, logging_userindex and logging_logindex) transparently. This allows you to write one query that will run as expected on either schema.

At the moment, the [//pythonhosted.org/mwdb/schema.html#mwdb.Schema.execute execute] method does not make any such conversion, but a helper attribute [//pythonhosted.org/mwdb/schema.html#mwdb.Schema.public_replica public_replica] that is True when querying views via a public replica and False when querying the production database.