def output_type_handler(cursor, name, default_type, size, precision, scale): if default_type == cx_Oracle.NUMBER: if not dialect.coerce_to_decimal: return None elif precision == 0 and scale in (0, -127): # ambiguous type, this occurs when selecting # numbers from deep subqueries return cursor.var( cx_Oracle.STRING, 255, outconverter=dialect._detect_decimal, arraysize=cursor.arraysize) elif precision and scale > 0: return number_handler( cursor, name, default_type, size, precision, scale ) else: return float_handler( cursor, name, default_type, size, precision, scale ) # allow all strings to come back natively as Unicode elif dialect.coerce_to_unicode and \ default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR): if compat.py2k: outconverter = processors.to_unicode_processor_factory( dialect.encoding, None) return cursor.var( cx_Oracle.STRING, size, cursor.arraysize, outconverter=outconverter ) else: return cursor.var( util.text_type, size, cursor.arraysize ) elif dialect.auto_convert_lobs and default_type in ( cx_Oracle.CLOB, cx_Oracle.NCLOB ): if compat.py2k: outconverter = processors.to_unicode_processor_factory( dialect.encoding, None) return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: outconverter(value.read()) ) else: return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: value.read() ) elif dialect.auto_convert_lobs and default_type in ( cx_Oracle.BLOB, ): return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: value.read() )
def output_type_handler(cursor, name, default_type, size, precision, scale): if default_type == cx_Oracle.NUMBER: if not dialect.coerce_to_decimal: return None elif precision == 0 and scale in (0, -127): # ambiguous type, this occurs when selecting # numbers from deep subqueries return cursor.var( cx_Oracle.STRING, 255, outconverter=dialect._detect_decimal, arraysize=cursor.arraysize) elif precision and scale > 0: return number_handler( cursor, name, default_type, size, precision, scale ) else: return float_handler( cursor, name, default_type, size, precision, scale ) # allow all strings to come back natively as Unicode elif dialect.coerce_to_unicode and \ default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR): if compat.py2k: outconverter = processors.to_unicode_processor_factory( dialect.encoding, None) return cursor.var( cx_Oracle.STRING, size, cursor.arraysize, outconverter=outconverter ) else: return cursor.var( util.text_type, size, cursor.arraysize ) elif dialect.auto_convert_lobs and default_type in ( cx_Oracle.CLOB, cx_Oracle.NCLOB ): if compat.py2k: outconverter = processors.to_unicode_processor_factory( dialect.encoding, None) return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: outconverter(value.read()) ) else: return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: value.read() ) elif dialect.auto_convert_lobs and default_type in ( cx_Oracle.BLOB, ): return cursor.var( default_type, size, cursor.arraysize, outconverter=lambda value: value.read() )
def __init__(self, convert_unicode=False, assert_unicode=False, encoding='utf-8', paramstyle=None, dbapi=None, implicit_returning=None, label_length=None, **kwargs): if not getattr(self, 'ported_sqla_06', True): util.warn( "The %s dialect is not yet ported to SQLAlchemy 0.6/0.7" % self.name) self.convert_unicode = convert_unicode if assert_unicode: util.warn_deprecated( "assert_unicode is deprecated. " "SQLAlchemy emits a warning in all cases where it " "would otherwise like to encode a Python unicode object " "into a specific encoding but a plain bytestring is " "received. " "This does *not* apply to DBAPIs that coerce Unicode " "natively.") self.encoding = encoding self.positional = False self._ischema = None self.dbapi = dbapi if paramstyle is not None: self.paramstyle = paramstyle elif self.dbapi is not None: self.paramstyle = self.dbapi.paramstyle else: self.paramstyle = self.default_paramstyle if implicit_returning is not None: self.implicit_returning = implicit_returning self.positional = self.paramstyle in ('qmark', 'format', 'numeric') self.identifier_preparer = self.preparer(self) self.type_compiler = self.type_compiler(self) if label_length and label_length > self.max_identifier_length: raise exc.ArgumentError( "Label length of %d is greater than this dialect's" " maximum identifier length of %d" % (label_length, self.max_identifier_length)) self.label_length = label_length if self.description_encoding == 'use_encoding': self._description_decoder = processors.to_unicode_processor_factory( encoding) elif self.description_encoding is not None: self._description_decoder = processors.to_unicode_processor_factory( self.description_encoding) self._encoder = codecs.getencoder(self.encoding) self._decoder = processors.to_unicode_processor_factory(self.encoding)
def __init__( self, convert_unicode=False, assert_unicode=False, encoding="utf-8", paramstyle=None, dbapi=None, implicit_returning=None, label_length=None, **kwargs ): if not getattr(self, "ported_sqla_06", True): util.warn("The %s dialect is not yet ported to SQLAlchemy 0.6/0.7" % self.name) self.convert_unicode = convert_unicode if assert_unicode: util.warn_deprecated( "assert_unicode is deprecated. " "SQLAlchemy emits a warning in all cases where it " "would otherwise like to encode a Python unicode object " "into a specific encoding but a plain bytestring is " "received. " "This does *not* apply to DBAPIs that coerce Unicode " "natively." ) self.encoding = encoding self.positional = False self._ischema = None self.dbapi = dbapi if paramstyle is not None: self.paramstyle = paramstyle elif self.dbapi is not None: self.paramstyle = self.dbapi.paramstyle else: self.paramstyle = self.default_paramstyle if implicit_returning is not None: self.implicit_returning = implicit_returning self.positional = self.paramstyle in ("qmark", "format", "numeric") self.identifier_preparer = self.preparer(self) self.type_compiler = self.type_compiler(self) if label_length and label_length > self.max_identifier_length: raise exc.ArgumentError( "Label length of %d is greater than this dialect's" " maximum identifier length of %d" % (label_length, self.max_identifier_length) ) self.label_length = label_length if self.description_encoding == "use_encoding": self._description_decoder = processors.to_unicode_processor_factory(encoding) elif self.description_encoding is not None: self._description_decoder = processors.to_unicode_processor_factory(self.description_encoding) self._encoder = codecs.getencoder(self.encoding) self._decoder = processors.to_unicode_processor_factory(self.encoding)
def go(): to_unicode_processor_factory("utf8")
def go(): to_unicode_processor_factory("utf8")
def go(): to_unicode_processor_factory('utf8')
def go(): to_unicode_processor_factory('utf8')