- changed watchers to jaimy.azle@gmail.com
support driver specification via entry points
This would include both existing databases with just the driver coming from an entry point, as well as the database+driver coming from an entrypoint.
patch, untested:
diff -r 13897cb81bfcbf24c2e96cd22f61a7d42cff4ca8 lib/sqlalchemy/engine/url.py
--- a/lib/sqlalchemy/engine/url.py Fri Sep 23 22:25:31 2011 -0400
+++ b/lib/sqlalchemy/engine/url.py Fri Sep 23 22:33:28 2011 -0400
@@ -104,7 +104,14 @@
module = __import__('sqlalchemy.dialects.%s' % (dialect, )).dialects
module = getattr(module, dialect)
- module = getattr(module, driver)
+ if hasattr(module, driver):
+ module = getattr(module, driver)
+ else:
+ module = self._load_entry_point()
+ if module is None:
+ raise exc.ArgumentError(
+ "Could not determine dialect for '%s'." %
+ self.drivername)
return module.dialect
except ImportError:
@@ -128,7 +135,7 @@
return None
for res in pkg_resources.iter_entry_points('sqlalchemy.dialects'):
- if res.name == self.drivername:
+ if res.name == self.drivername.replace("+", "."):
return res.load()
else:
return None
Comments (7)
-
reporter -
Account Deleted I think this is much better as it enabling the use of alt. driver for already supported database, not only for unsupported database. Thank you Michael.
-Jaimy.
-
reporter I'm basically going to commit it, so let me know that it actually works as expected.
-
Account Deleted Confirmed works Michael, I try it both on CPython and Jython.
-Jaimy.
(sqltest) D:\Projects\sqltest\SQLAlchemy-0.7.2>python sqla_nose.py --verbose --dburi=ibm_db_sa+pyodbc://user:passwd@aa.bb.cc.dd:50000/USERDB D:\Projects\sqltest\lib\site-packages\nose-1.1.2-py2.6.egg\nose\plugins\manager. py:383: RuntimeWarning: Unable to load plugin pylons = pylons.test:PylonsPlugin: Beaker>=1.3dev RuntimeWarning) D:\Projects\sqltest\lib\site-packages\sqlalchemy-0.7.2-py2.6.egg\sqlalchemy\dial ects\access\base.py:162: SAWarning: The access dialect is not yet ported to SQLA lchemy 0.6/0.7 super(AccessDialect, self).__init__(**params) test.aaa_profiling.test_compiler.CompileTest.test_insert ... ok test.aaa_profiling.test_compiler.CompileTest.test_select ... ok test.aaa_profiling.test_compiler.CompileTest.test_update ... ok test.aaa_profiling.test_compiler.CompileTest.test_update_whereclause ... ok ... (sqltest) D:\Projects\sqltest\SQLAlchemy-0.7.2>jython sqla_nose.py --verbose --dburi=ibm_db_sa+zxjdbc://user:passwd@aa.bb.cc.dd:50000/USERDB C:\Java\app\jython\Lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\diale cts\access\base.py:162: SAWarning: The access dialect is not yet ported to SQLAl chemy 0.6/0.7 super(AccessDialect, self).__init__(**params) test.base.test_dependency.DependencySortTest.test_find_cycle_one ... ok ...
-
reporter - changed status to resolved
great. is this IBM-DB's official release ? I can put an announcement up if IBM-DB has a SQLAlchemy 0.7 dialect now. patch is in e80b725a953d153b132bce62564cbf6b773a8769
-
Account Deleted Currently it is still an unofficial update (https://bitbucket.org/jazle/ibm_db_sa), I would propose myself as maintainer for ibm_db_sa, perhaps within next week. I will inform you later on this, once it is done.
-Jaimy.
-
reporter - removed milestone
Removing milestone: 0.7.3 (automated comment)
- Log in to comment