本文整理匯總了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