Re: [cx-oracle-users] setinputsizes (Was: Inserting on table where is CLOB column)
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2005-05-18 13:31:19
|
On 5/18/05, Jani Tiainen <re...@lu...> wrote: > Jani Tiainen kirjoitti: >=20 > > In application code insert clause is in form: > > > > sql =3D "INSERT INTO FOOBAR (ID, VALUE, CLOB_VALUE) VALUES (%s, %s, %s)= " > > params =3D (1, 'foobar', 'verylongfoobar') > > > > This is converted to format: > > > > sql =3D "INSERT INTO FOOBAR (ID, VALUE, CLOB_VALUE) VALUES (:val1, :val= 2, > > :val3)" > > params =3D {'val1' : 1, 'val2' : 'foobar', 'val3' : 'verylongfoobar'} > > > > Now this works as long as string I'm trying to insert doesn't exceed > > 4000 chars. If that happens it tries insert LONG to CLOB column. > > > > I've tried following piece of code: > > > > # Adjust inputsizes.. > > inputsizes =3D {} > > for k, v in params.items(): > > if type(v) is str and len(v) > 4000: > > inputsizes[k] =3D cx_Oracle.CLOB > > else: > > inputsizes[k] =3D None > > > > cursor.setinputsizes(inputsizes) > > > > And I always endup having "cx_Oracle.NotSupportedError: > > Variable_TypeByPythonType(): unhandled data type" error. Even I remove > > else-branch final result is still same. > > > > Even I used cx_Oracle.STRING instead of None result was same. > > >=20 > Only occassion when abowe works is when named parameters are passed. >=20 > Even following doesn't seem to work: >=20 > cursor.setinputvalues([None, cx_Oracle.CLOB]) > cursor.execute("INSERT INTO FOOBAR(ID, CLOB_VAR) VALUES (:1, :2)", > [{'1' : 1002}, {'2' : 'longfoobartext'}]) This should be cursor.execute(insert_statement, [1002, 'longfoobartext']) In other words, you should not pass a dictionary for positional arguments but a sequence instead. > Any ideas why it always gives error except in case of named params? >=20 > -- >=20 > Jani Tiainen >=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_id=3D7412&alloc_id=3D16344&op=3Dclick > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |