diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-17 20:49:35 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-17 20:49:35 +0000 |
commit | aabb6e530b05bee9cc5c2382a308a987abd6168e (patch) | |
tree | cd937947baf100d75e679e2f6d40e3a287ffc196 /lib/sqlalchemy/databases/sqlite.py | |
parent | 8d7a271b8687dbcb58cac713f9e16e445d242881 (diff) | |
download | sqlalchemy-aabb6e530b05bee9cc5c2382a308a987abd6168e.tar.gz |
- the dialects within sqlalchemy.databases become a setuptools
entry points. loading the built-in database dialects works the
same as always, but if none found will fall back to trying
pkg_resources to load an external module [ticket:521]
Diffstat (limited to 'lib/sqlalchemy/databases/sqlite.py')
-rw-r--r-- | lib/sqlalchemy/databases/sqlite.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index 2b7e28dfb..0222496f8 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -12,18 +12,6 @@ import sqlalchemy.engine.default as default import sqlalchemy.types as sqltypes import datetime,time -def dbapi(): - try: - from pysqlite2 import dbapi2 as sqlite - except ImportError, e: - try: - from sqlite3 import dbapi2 as sqlite #try the 2.5+ stdlib name. - except ImportError: - try: - sqlite = __import__('sqlite') # skip ourselves - except ImportError: - raise e - return sqlite class SLNumeric(sqltypes.Numeric): def get_col_spec(self): @@ -160,6 +148,20 @@ class SQLiteDialect(ansisql.ANSIDialect): return tuple([int(x) for x in num.split('.')]) self.supports_cast = (self.dbapi is None or vers(self.dbapi.sqlite_version) >= vers("3.2.3")) + def dbapi(cls): + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError, e: + try: + from sqlite3 import dbapi2 as sqlite #try the 2.5+ stdlib name. + except ImportError: + try: + sqlite = __import__('sqlite') # skip ourselves + except ImportError: + raise e + return sqlite + dbapi = classmethod(dbapi) + def compiler(self, statement, bindparams, **kwargs): return SQLiteCompiler(self, statement, bindparams, **kwargs) @@ -347,4 +349,4 @@ class SQLiteIdentifierPreparer(ansisql.ANSIIdentifierPreparer): super(SQLiteIdentifierPreparer, self).__init__(dialect, omit_schema=True) dialect = SQLiteDialect -poolclass = pool.SingletonThreadPool +dialect.poolclass = pool.SingletonThreadPool |