On Jun 21, 2007, at 8:04 PM, [EMAIL PROTECTED] wrote:
> > Hello, > > Based on http://www.sqlalchemy.org/trac/ticket/435 and a perusal of > the source it seems to me that the sqlalchemy fetchall method with > cx_Oracle supports retrieving multiple rows of an Oracle table that > has CLOBs or BLOBs. I am having troubles though. I am either wrong > about sqlalchemy having that feature, I am using it incorrectly or > there is perhaps a bug. > > Here is a sql script to create a test table and populate the test > table: > drop table test; > create table test (a_clob clob); > insert into test (a_clob) values ('This is a test'); > insert into test (a_clob) values ('This is another test'); > commit; > > Here is a test script that throws an error when retrieving the rows of > CLOBs with a fetchall: > #!/usr/bin/python > from sqlalchemy import create_engine > import cx_Oracle > > db = create_engine("oracle://user:[EMAIL PROTECTED]"); > conn = db.connect() > proxy = conn.execute("select a_clob from test"); > rows = proxy.fetchall() > > for i in rows: > for j in i.values(): > print j > yes, this is because your straight textual SQL does not add any TypeEngine processing to the result set. the BufferedColumnResultProxy is correctly used, but when it fully fetches each row, it still only sees a cx_oracle.LOB (which in your second test is converting to a string on your end). the immediate workaround is to issue the query like this: proxy = conn.execute(text("select a_clob from test", typemap= {'a_clob':Binary})); however, seeing that OracleDialect is already making the effort to search for LOBs in all result sets, I added a flag in r2762 "auto_convert_lobs=True", such that if no typemap is present, it will create one, adding in OracleBinary which does the LOB conversion. so your test case will work as is as of 2762. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---