SQLAlchemy ResultProxy is set up by the cx_oracle dialect to add the sqlalchemy.dialect.oracle.CLOB type into any result set with a CLOB which intercepts cx_oracle's LOB and converts to a stream. If you are using a SQLAlchemy engine and not the cx_oracle cursor directly you should not be getting the LOB back.
from sqlalchemy import *
e = create_engine('oracle://scott:tiger@localhost/xe', echo=True)
m = MetaData()
t = Table('x', m, Column('id', Integer, primary_key=True), Column('data', Text))
m.drop_all(e)
m.create_all(e)
e.execute(t.insert().values(id=1, data='adjfnadkjfdanfkjdanjkdn'))
for row in e.execute(t.select()):
print row['data']
# works with plain SQL too, SQLA uses cursor.description for this particular type of conversion:
for row in e.execute("SELECT data FROM x"):
print row['data']
CREATE TABLE x (
id INTEGER NOT NULL,
data CLOB,
PRIMARY KEY (id)
)
INSERT INTO x (id, data) VALUES (:id, :data)
{'data': 'adjfnadkjfdanfkjdanjkdn', 'id': 1}
FROM x
adjfnadkjfdanfkjdanjkdn
SELECT data FROM x
{}
adjfnadkjfdanfkjdanjkdn