moskytw/mosql — pull request #26 by uranusjr (2013-11-23 12:12:01+00:00)
Title: Alternative implementation for patching

See also #24 #25.

A slightly complicated version of context manager patching mechanism. Introduce mosql.patch to handle all (well, both) engines. The idea is mostly the same, only the function names are different:

```python
from mosql import patch

with patch.mysql():
select(...) # MySQL
with patch.sqlite():
select(...) # SQLite
select(...) # MySQL again
select(...) # Standard
```

For perminante overriding, use `mysql.load()` and `sqlite.load()`. They also return a `dict` of replaced functions.

An important aspect of this version is that it is **backward compatible**. Both `import mosql.mysql` and `import mosql.sqlite` will continue to work, although I recommand deprecation.

Some docs and tests are attached, but consider them incomplete because there're more structural changes in this version.