diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-11 02:23:32 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-11 02:23:32 +0000 |
commit | 44626e96595f25f9580e45ffa930fdec0f1b07a8 (patch) | |
tree | c478fa954db1fac6a56189003eed28f21fdff61e /lib/sqlalchemy/dialects/sqlite/base.py | |
parent | e38b11928a4d0902dde5c45e0df99565df85d6ba (diff) | |
download | sqlalchemy-44626e96595f25f9580e45ffa930fdec0f1b07a8.tar.gz |
- Added "native_datetime=True" flag to create_engine().
This will cause the DATE and TIMESTAMP types to skip
all bind parameter and result row processing, under
the assumption that PARSE_DECLTYPES has been enabled
on the connection. Note that this is not entirely
compatible with the "func.current_date()", which
will be returned as a string. [ticket:1685]
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 93e62ec24..696f65a6c 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -76,19 +76,16 @@ class _SLNumeric(_NumericMixin, sqltypes.Numeric): class _SLFloat(_NumericMixin, sqltypes.Float): pass -# since SQLite has no date types, we're assuming that SQLite via ODBC -# or JDBC would similarly have no built in date support, so the "string" based logic -# would apply to all implementing dialects. class _DateTimeMixin(object): _reg = None _storage_format = None - + def __init__(self, storage_format=None, regexp=None, **kwargs): if regexp is not None: self._reg = re.compile(regexp) if storage_format is not None: self._storage_format = storage_format - + def _result_processor(self, fn): rmatch = self._reg.match # Even on python2.6 datetime.strptime is both slower than this code @@ -342,7 +339,7 @@ class SQLiteDialect(default.DefaultDialect): supports_default_values = True supports_empty_insert = False supports_cast = True - + default_paramstyle = 'qmark' statement_compiler = SQLiteCompiler ddl_compiler = SQLiteDDLCompiler @@ -352,7 +349,7 @@ class SQLiteDialect(default.DefaultDialect): colspecs = colspecs isolation_level = None - def __init__(self, isolation_level=None, **kwargs): + def __init__(self, isolation_level=None, native_datetime=False, **kwargs): default.DefaultDialect.__init__(self, **kwargs) if isolation_level and isolation_level not in ('SERIALIZABLE', 'READ UNCOMMITTED'): @@ -360,7 +357,13 @@ class SQLiteDialect(default.DefaultDialect): "Valid isolation levels for sqlite are 'SERIALIZABLE' and " "'READ UNCOMMITTED'.") self.isolation_level = isolation_level - + + # this flag used by pysqlite dialect, and perhaps others in the + # future, to indicate the driver is handling date/timestamp + # conversions (and perhaps datetime/time as well on some + # hypothetical driver ?) + self.native_datetime = native_datetime + def visit_pool(self, pool): if self.isolation_level is not None: class SetIsolationLevel(object): |