Wikia/python-commons — pull request #7 by wladekb (2014-10-29 18:06:01+00:00)
Title: wikia.common.mediawiki.database - call for comments

Preview of the new mediawiki database module. It's an improved version of Garth's work that simplifies the API (#3).

Please do not merge, it's just a call for comments PR for now.

Example code using this module:

```python
import wikia.common.mediawiki.database

load_balancer = wikia.common.mediawiki.database.LoadBalancer()

# how to connect to shared or wiki-specific databases
conn = load_balancer.get_connection('wikicities') # defaults to SLAVE and no "groups"
conn = load_balancer.get_connection('muppet',load_balancer.MASTER) # connect to master db of muppet wiki
conn = load_balancer.get_connection('stats') # connects to stats special cluster
conn = load_balancer.get_connection('muppet',groups='slow') # connect to muppet wiki using a server marked for 'slow' queries

# So-called external sections are currently used only for blobs storage
blobs_conn = load_balancer.get_external_connection('archive1') # connect to archive1 blobs db
```

This API seems to be easier to work with (than #3) and more consistent with MediaWiki's original API which is commonly known and is plain simple.

The major plan includes writing parallel implementations of this module in other languages that we use at Wikia. This convinced me to write the code in such a way that it's easier to translate to other languages and it might not look like a typical python code. Please also comment on this decision.

@Wikia/platform-team @garthwebb pls review and comment