On Sep 25, 2008, at 2:37 PM, MHC wrote:
> > Perhaps someone can comment on this question about Oracle BFILE's. > (Oracle BFILE's are like BLOB's but the data is kept outside the > database tables, in regular files on disk. Each BFILE has a directory > and filename entry in the table that points to the file on disk). > > SQLAlchemy handles BFILE's in the same way as BLOB's, and they work > nicely, with one exception. BFILE's have several methods that can be > called on the LOB handle, and there doesn't appear to be a way in > SQLAlchemy that one can call these methods. In particular it would be > very useful to be able to call getfilename() and fileexists(). These > are implemented in cx_Oracle, so the underlying facility is available. > SQLAlchemy always gets the data with read() and returns the data. > > In the particular application I'm working on the user can upload > various files to a database and these are stored as BFILE's. The user > can also browse through the database in various ways, and what he > wants to see at first is the name of the file he uploaded (that is, > from lob.getfilename()), rather than the contents of the file. > > Is there a way to call getfilename() on a BFILE column currently, or > could that be implemented? SQLAlchemy's default handling of all "streamed" oracle objects like BLOB, BFILE, etc. is to pre-read the contents of them into the result set. The rationale here is that cursor methods like fetchmany() and fetchall() can be used without the cursor associated with the individual column objects getting lost, if more than cursor.arraysize rows have been read (we currently set cursor.arraysize to 50). It is also so that the binary data returned by the result row is directly compatible with that of all other DBAPIs. Recognizing the usefulness of cx_oracle's LOB object, SQLAlchemy allows one to disable this behavior by sending the parameter auto_convert_lobs=False to your create_engine() call. You'll then get the LOB objects directly present in your result rows. These need to be consumed before the next page of data is fetched from the database (i.e., within every group of "arraysize" rows, which is 50 by default but can also be configured using the "arraysize" parameter to create_engine()). Going to add a note of this now to http://www.sqlalchemy.org/trac/wiki/DatabaseNotes . --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---