diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-28 15:53:18 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-28 15:53:18 +0000 |
| commit | e7da05f64eee0177b43162301710012211377a8e (patch) | |
| tree | a92af343fed4c6814f294427dd877099bca9fc59 /lib/sqlalchemy/engine/base.py | |
| parent | e0b638a704f7f0abf88d1a80a95cf052954e048c (diff) | |
| download | sqlalchemy-e7da05f64eee0177b43162301710012211377a8e.tar.gz | |
added "supports_unicode_statements()" step to dialect/execute_raw so that DB's like oracle can opt out of unicode statement strings
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index c2ae272f5..cf0d35035 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -111,6 +111,10 @@ class Dialect(sql.AbstractDialect): Return None if no limit.""" return None + def supports_unicode_statements(self): + """indicate whether the DBAPI can receive SQL statements as Python unicode strings""" + raise NotImplementedError() + def supports_sane_rowcount(self): """Indicate whether the dialect properly implements statements rowcount. @@ -544,6 +548,9 @@ class Connection(Connectable): def _execute_raw(self, statement, parameters=None, cursor=None, context=None, **kwargs): if cursor is None: cursor = self.__engine.dialect.create_cursor(self.connection) + if not self.__engine.dialect.supports_unicode_statements(): + # encode to ascii, with full error handling + statement = statement.encode('ascii') self.__engine.logger.info(statement) self.__engine.logger.info(repr(parameters)) if parameters is not None and isinstance(parameters, list) and len(parameters) > 0 and (isinstance(parameters[0], list) or isinstance(parameters[0], dict)): |
