Also see: #24. I didn't implement "unload" because it could be pretty messy when there are nested or even interlaced apply-restore pairs.
With this implementation, users have two choices:
Use the context manager to mix different database engines
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
If the user only wants to work with one specific database
# 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.
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.
Also see: #24. I didn't implement "unload" because it could be pretty messy when there are nested or even interlaced apply-restore pairs.
With this implementation, users have two choices:
Use the context manager to mix different database engines
If the user only wants to work with one specific database
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.
I have also added/modified some documentation and tests.