<li>use_ansi=True : used only by Oracle; when False, the Oracle driver attempts to support a particular "quirk" of some Oracle databases, that the LEFT OUTER JOIN SQL syntax is not supported, and the "Oracle join" syntax of using <% "<column1>(+)=<column2>" |h%> must be used in order to achieve a LEFT OUTER JOIN. Its advised that the Oracle database be configured to have full ANSI support instead of using this feature.</li>
<li>use_oids=False : used only by Postgres, will enable the column name "oid" as the object ID column. Postgres as of 8.1 has object IDs disabled by default.</li>
<li>convert_unicode=False : if set to True, all String/character based types will convert Unicode values to raw byte values going into the database, and all raw byte values to Python Unicode coming out in result sets. This is an engine-wide method to provide unicode across the board. For unicode conversion on a column-by-column level, use the Unicode column type instead.</li>
+ <li>encoding='utf-8' : the encoding to use when doing unicode translations.</li>
</ul>
</&>
<&|doclib.myt:item, name="proxy", description="Using the Proxy Engine" &>
SQLEngines are constructed via the create_engine() function inside this package.
"""
- def __init__(self, pool=None, echo=False, logger=None, default_ordering=False, echo_pool=False, echo_uow=False, convert_unicode=False, **params):
+ def __init__(self, pool=None, echo=False, logger=None, default_ordering=False, echo_pool=False, echo_uow=False, convert_unicode=False, encoding='utf-8', **params):
"""constructs a new SQLEngine. SQLEngines should be constructed via the create_engine()
function which will construct the appropriate subclass of SQLEngine."""
# get a handle on the connection pool via the connect arguments
self.echo = echo
self.echo_uow = echo_uow
self.convert_unicode = convert_unicode
+ self.encoding = encoding
self.context = util.ThreadLocal(raiseerror=False)
self._ischema = None
self._figure_paramstyle()
if not engine.convert_unicode or value is None or not isinstance(value, unicode):
return value
else:
- return value.encode('utf-8')
+ return value.encode(engine.encoding)
def convert_result_value(self, value, engine):
if not engine.convert_unicode or value is None or isinstance(value, unicode):
return value
else:
- return value.decode('utf-8')
+ return value.decode(engine.encoding)
def adapt_args(self):
if self.length is None:
return TEXT()
class Unicode(String):
def convert_bind_param(self, value, engine):
if isinstance(value, unicode):
- return value.encode('utf-8')
+ return value.encode(engine.encoding)
else:
return value
def convert_result_value(self, value, engine):
if not isinstance(value, unicode):
- return value.decode('utf-8')
+ return value.decode(engine.encoding)
else:
return value