How do I set up an engine so that Oracle Number fields are not
converted to Decimal?

I'm dealing with a bunch of code with hand-rolled SQL query strings,
and as the first step was going to use connections from SqlAlchemy's
connection pool, as I change the queries one-by-one.  The only problem
is that our main queries get 500 Number columns and SqlAlchemy is
converting them to Decimals, slowing the queries down by a factor of
10.

Here's an example

>>> engine = sqlalchemy.create_engine("oracle+cx_oracle://"+connString)
>>> conn = engine.pool.connect()
>>> cursor = conn.cursor()
>>> cursor.execute("""SELECT * FROM MY_TABLE""")
>>> r = cursor.fetchone()
>>> r[-1]
Decimal('0.878935370620606')

The conversion is done via the outputtypehandler of the connection
object.  I can circumvent it by either setting

>>> cursor.connection.outputtypehandler = None

or

>>> cursor.outputtypehandler = lambda *args : None

but is there a better, more standard way to convert the Numbers to
floats and not Decimals for arbitrary queries?

(Setting engine.dialect.supports_native_decimal to False doesn't work.
 I believe the dialect is creating the output type handler before any
connection is opened.)

-- 
--Anthony

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to