当前位置: 首页>>代码示例>>Python>>正文


Python processors.to_float方法代码示例

本文整理汇总了Python中sqlalchemy.processors.to_float方法的典型用法代码示例。如果您正苦于以下问题:Python processors.to_float方法的具体用法?Python processors.to_float怎么用?Python processors.to_float使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.processors的用法示例。


在下文中一共展示了processors.to_float方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bind_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def bind_processor(self, dialect):
        super_process = super(_SybNumeric_pyodbc, self).\
            bind_processor(dialect)

        def process(value):
            if self.asdecimal and \
                    isinstance(value, decimal.Decimal):

                if value.adjusted() < -6:
                    return processors.to_float(value)

            if super_process:
                return super_process(value)
            else:
                return value
        return process 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:pyodbc.py

示例2: bind_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def bind_processor(self, dialect):
        super_process = super(_SybNumeric_pyodbc, self).\
                                    bind_processor(dialect)

        def process(value):
            if self.asdecimal and \
                    isinstance(value, decimal.Decimal):

                if value.adjusted() < -6:
                    return processors.to_float(value)

            if super_process:
                return super_process(value)
            else:
                return value
        return process 
开发者ID:binhex,项目名称:moviegrabber,代码行数:18,代码来源:pyodbc.py

示例3: result_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def result_processor(self, dialect, coltype):
        # we apply a cx_oracle type handler to all connections
        # that converts floating point strings to Decimal().
        # However, in some subquery situations, Oracle doesn't
        # give us enough information to determine int or Decimal.
        # It could even be int/Decimal differently on each row,
        # regardless of the scale given for the originating type.
        # So we still need an old school isinstance() handler
        # here for decimals.

        if dialect.supports_native_decimal:
            if self.asdecimal:
                fstring = "%%.%df" % self._effective_decimal_return_scale

                def to_decimal(value):
                    if value is None:
                        return None
                    elif isinstance(value, decimal.Decimal):
                        return value
                    else:
                        return decimal.Decimal(fstring % value)

                return to_decimal
            else:
                if self.precision is None and self.scale is None:
                    return processors.to_float
                elif not getattr(self, '_is_oracle_number', False) \
                        and self.scale is not None:
                    return processors.to_float
                else:
                    return None
        else:
            # cx_oracle 4 behavior, will assume
            # floats
            return super(_OracleNumeric, self).\
                result_processor(dialect, coltype) 
开发者ID:jpush,项目名称:jbox,代码行数:38,代码来源:cx_oracle.py

示例4: result_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:pysybase.py

示例5: bind_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def bind_processor(self, dialect):
        super_process = super(_SybNumeric_pyodbc, self).bind_processor(dialect)

        def process(value):
            if self.asdecimal and isinstance(value, decimal.Decimal):

                if value.adjusted() < -6:
                    return processors.to_float(value)

            if super_process:
                return super_process(value)
            else:
                return value

        return process 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:pyodbc.py

示例6: result_processor

# 需要导入模块: from sqlalchemy import processors [as 别名]
# 或者: from sqlalchemy.processors import to_float [as 别名]
def result_processor(self, dialect, coltype):
        # we apply a cx_oracle type handler to all connections
        # that converts floating point strings to Decimal().
        # However, in some subquery situations, Oracle doesn't
        # give us enough information to determine int or Decimal.
        # It could even be int/Decimal differently on each row,
        # regardless of the scale given for the originating type.
        # So we still need an old school isinstance() handler
        # here for decimals.

        if dialect.supports_native_decimal:
            if self.asdecimal:
                fstring = "%%.%df" % self._effective_decimal_return_scale

                def to_decimal(value):
                    if value is None:
                        return None
                    elif isinstance(value, decimal.Decimal):
                        return value
                    else:
                        return decimal.Decimal(fstring % value)

                return to_decimal
            else:
                if self.precision is None and self.scale is None:
                    return processors.to_float
                elif not getattr(self, '_is_oracle_number', False) \
                    and self.scale is not None:
                    return processors.to_float
                else:
                    return None
        else:
            # cx_oracle 4 behavior, will assume
            # floats
            return super(_OracleNumeric, self).\
                            result_processor(dialect, coltype) 
开发者ID:binhex,项目名称:moviegrabber,代码行数:38,代码来源:cx_oracle.py


注:本文中的sqlalchemy.processors.to_float方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。