Re: [cx-oracle-users] Inserting on table where is CLOB column
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2005-05-17 19:25:24
|
On 5/17/05, Guido van Rossum <gu...@el...> wrote: > > connection =3D cx_Oracle.Connection("user/pw@tns") > > cursor =3D connection.cursor() > > cursor.setinputsizes(value =3D cx_Oracle.CLOB) > > cursor.execute("insert into table values (:value)", > > value =3D "A very long string") >=20 > setinputsizes() isn't documented very clearly if you don't already know > what it does. Could someone here explain its use (and for bonus points, > the use of setoutputsizes() as well)? setinputsizes() is used to define what type (and size) of data is being bound to the cursor. In most cases cx_Oracle (and other database access modules) can guess the type from the type of the Python value that is bound but the Python None value (representing null in database terms) doesn't have any type that corresponds to any database type. Thus, if you want to bind a NULL or anything else (like CLOB/BLOB) where the database type and size cannot be implied from the Python type and size you want to use setinputsizes(). setoutputsizes() is for defining the size of data that is being fetched from the database. In particular it is used for variable length data (like long and long raw in Oracle) where the size cannot be known by retrieving the information from the database. If you never use long or long raw (and Oracle recommends that you use CLOB and BLOB instead) then you never need to know about this function. Does that help?? How many bonus points do I get?? :-) > --Guido van Rossum (home page: http://www.python.org/~guido) >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_idt12&alloc_id=16344&opclick > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |