moskytw/mosql — pull request #25 by uranusjr (2013-11-23 10:47:51+00:00)
Title: An implementation for #24

I didn't implement "unload" because it could be pretty messy when there are *nested* apply-restore pairs.

With this implementation, users have two choices:

1. Use the context manager to mix different database engines
```python
from mosql.query import *
from mosql import mysql, sqlite

select(...) # Standard
with mysql.apply():
select(...) # MySQL style
with sqlite.apply():
select(...) # SQLite style
select(...) # MySQL again
select(...) # Back to standard
```
2. If the user only wants to work with one specific database
```python
# These two lines is equivalent to the old "import mosql.mysql"
from mosql import mysql
mysql.load()
```
To compensate the absence of the "unload" functionality, "load" actually returns a dictionary of attributes that were replaced by it. Users can manually restore things back if they wish to.
```python
from mosql import mysql
backups = mysql.load()

# MySQL style now

import mosql.util
for k in backups:
setattr(mosql.util, k, backups[k])

# Back to standard
```
I have also added/modified some documentation and tests.