Python sqlalchemy.processors.to_float() Examples

The following are 23 code examples of sqlalchemy.processors.to_float(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.processors , or try the search function .
Example #1
Source File: pyodbc.py    From android_universal with MIT License 6 votes vote down vote up
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 
Example #2
Source File: pyodbc.py    From jbox with MIT License 6 votes vote down vote up
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 
Example #3
Source File: pyodbc.py    From moviegrabber with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #4
Source File: pyodbc.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #5
Source File: pyodbc.py    From planespotter with MIT License 6 votes vote down vote up
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 
Example #6
Source File: pyodbc.py    From jarvis with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #7
Source File: pyodbc.py    From pyRevit with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #8
Source File: pyodbc.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #9
Source File: cx_oracle.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #10
Source File: pysybase.py    From android_universal with MIT License 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #11
Source File: pysybase.py    From moviegrabber with GNU General Public License v3.0 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #12
Source File: cx_oracle.py    From moviegrabber with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #13
Source File: pysybase.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #14
Source File: pyodbc.py    From sqlalchemy with MIT License 5 votes vote down vote up
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 
Example #15
Source File: pysybase.py    From sqlalchemy with MIT License 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #16
Source File: pysybase.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #17
Source File: cx_oracle.py    From jbox with MIT License 5 votes vote down vote up
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) 
Example #18
Source File: pysybase.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #19
Source File: cx_oracle.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #20
Source File: pysybase.py    From planespotter with MIT License 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #21
Source File: pysybase.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_) 
Example #22
Source File: cx_oracle.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #23
Source File: pysybase.py    From jbox with MIT License 5 votes vote down vote up
def result_processor(self, dialect, type_):
        if not self.asdecimal:
            return processors.to_float
        else:
            return sqltypes.Numeric.result_processor(self, dialect, type_)