Re: [cx-oracle-users] type object matching - BINARY
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2006-09-13 14:09:55
|
To answer your question: Oracle has three types that hold binary data -- RAW, LONG RAW and BLOB. They are all quite different as far as Oracle is concerned so some means of dealing with that is rather important -- they cannot simply be the same type. If you're dealing with Oracle you'll have to deal with this issue -- there is no database independent way to deal with it that I am aware of. Please feel free to educate me if necessary. :-) In addition, Python doesn't really have a concept of "binary" data -- it stores everything in "strings". Its just that some of those "strings" are not null terminated. :-) I've taken advantage of that and not bothered with a "Binary()" constructor since I figured that you can create strings in Python just fine already. Use setinputsizes() to specify to Oracle how to interpret that data. BTW, CLOB is not binary data but text data and LOB is simply a way of indicating that a LOB (Large Object) indicator is present and nothing more. Does that answer your questions? On 9/13/06, Mario Frasca <mf...@zo...> wrote: > I've a question about this behaviour: > > >>> cx_Oracle.BINARY == cx_Oracle.BINARY > True > >>> cx_Oracle.BINARY == cx_Oracle.LOB > False > >>> cx_Oracle.BINARY == cx_Oracle.BLOB > False > >>> cx_Oracle.BINARY == cx_Oracle.CLOB > False > > is it correct? after reading the pep-249 at > http://www.python.org/dev/peps/pep-0249/, I would expect all of them to > check True. otherwise, how do I check if a field is holding a binary > object in a db-api2 compatible way? > > I've checked pgdb and MySQLdb and only MySQLdb recognizes a binary > object as above. > > how to test: > > import cx_Oracle, open a connection, associate cr to a cursor. > > >>> cr.execute('create table test(pk_test integer not null primary key, v_text clob)') > >>> cr.execute('select * from test') > [<cx_Oracle.NUMBER object at 0x40344ca0>, <cx_Oracle.CLOB object at 0x40311bd0>] > >>> cr.description[1][1] > <type 'cx_Oracle.CLOB'> > >>> cr.description[1][1] == cx_Oracle.BINARY > False > >>> > > regards, > MF > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |