Python cx_Oracle.NATIVE_FLOAT Examples

The following are 4 code examples of cx_Oracle.NATIVE_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 cx_Oracle , or try the search function .
Example #1
Source File: cx_oracle.py    From planespotter with MIT License 4 votes vote down vote up
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 
Example #2
Source File: cx_oracle.py    From sqlalchemy with MIT License 4 votes vote down vote up
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 
Example #3
Source File: cx_oracle.py    From jarvis with GNU General Public License v2.0 4 votes vote down vote up
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 
Example #4
Source File: cx_oracle.py    From android_universal with MIT License 4 votes vote down vote up
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