本文整理汇总了Python中cx_Oracle.NATIVE_FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.NATIVE_FLOAT属性的具体用法?Python cx_Oracle.NATIVE_FLOAT怎么用?Python cx_Oracle.NATIVE_FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cx_Oracle
的用法示例。
在下文中一共展示了cx_Oracle.NATIVE_FLOAT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cx_oracle_outputtypehandler
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import NATIVE_FLOAT [as 别名]
def _cx_oracle_outputtypehandler(self, dialect):
cx_Oracle = dialect.dbapi
is_cx_oracle_6 = dialect._is_cx_oracle_6
has_native_int = dialect._has_native_int
def handler(cursor, name, default_type, size, precision, scale):
outconverter = None
if precision:
if self.asdecimal:
if default_type == cx_Oracle.NATIVE_FLOAT:
# receiving float and doing Decimal after the fact
# allows for float("inf") to be handled
type_ = default_type
outconverter = decimal.Decimal
elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING
outconverter = dialect._to_decimal
else:
if self.is_number and scale == 0:
if has_native_int:
type_ = cx_Oracle.NATIVE_INT
else:
type_ = cx_Oracle.NUMBER
outconverter = int
else:
type_ = cx_Oracle.NATIVE_FLOAT
else:
if self.asdecimal:
if default_type == cx_Oracle.NATIVE_FLOAT:
type_ = default_type
outconverter = decimal.Decimal
elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING
outconverter = dialect._to_decimal
else:
if self.is_number and scale == 0:
if has_native_int:
type_ = cx_Oracle.NATIVE_INT
else:
type_ = cx_Oracle.NUMBER
outconverter = int
else:
type_ = cx_Oracle.NATIVE_FLOAT
return cursor.var(
type_, 255,
arraysize=cursor.arraysize,
outconverter=outconverter
)
return handler
示例2: _cx_oracle_outputtypehandler
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import NATIVE_FLOAT [as 别名]
def _cx_oracle_outputtypehandler(self, dialect):
cx_Oracle = dialect.dbapi
is_cx_oracle_6 = dialect._is_cx_oracle_6
def handler(cursor, name, default_type, size, precision, scale):
outconverter = None
if precision:
if self.asdecimal:
if default_type == cx_Oracle.NATIVE_FLOAT:
# receiving float and doing Decimal after the fact
# allows for float("inf") to be handled
type_ = default_type
outconverter = decimal.Decimal
elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING
outconverter = dialect._to_decimal
else:
if self.is_number and scale == 0:
# integer. cx_Oracle is observed to handle the widest
# variety of ints when no directives are passed,
# from 5.2 to 7.0. See [ticket:4457]
return None
else:
type_ = cx_Oracle.NATIVE_FLOAT
else:
if self.asdecimal:
if default_type == cx_Oracle.NATIVE_FLOAT:
type_ = default_type
outconverter = decimal.Decimal
elif is_cx_oracle_6:
type_ = decimal.Decimal
else:
type_ = cx_Oracle.STRING
outconverter = dialect._to_decimal
else:
if self.is_number and scale == 0:
# integer. cx_Oracle is observed to handle the widest
# variety of ints when no directives are passed,
# from 5.2 to 7.0. See [ticket:4457]
return None
else:
type_ = cx_Oracle.NATIVE_FLOAT
return cursor.var(
type_,
255,
arraysize=cursor.arraysize,
outconverter=outconverter,
)
return handler