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:
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.
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:For perminante overriding, use
mysql.load()
andsqlite.load()
. They also return adict
of replaced functions.An important aspect of this version is that it is backward compatible. Both
import mosql.mysql
andimport 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.