Re: [cx-oracle-users] Re: Inserting on table where is CLOB column
Brought to you by:
atuining
|
From: Anthony T. <ant...@gm...> - 2005-05-17 23:03:43
|
On 5/17/05, Jani Tiainen <re...@lu...> wrote:
> Anthony Tuininga kirjoitti:
> > On 5/17/05, Jani Tiainen <re...@lu...> wrote:
> >
> >>>BTW, if you __really__ have no control, you can always subclass
> >>>Connection and Cursor and do whatever you need to do. Subclassing has
> >>>been quite convenient and I use it myself for a number of situations
> >>>where the code is used by multiple database adapters.
> >>
> >>Any pointers in web (example would be nice) since I'm just becoming
> >>friend of Python and I might be trying to do things wrong here...
> >
> >
> > Recent e-mails to this list have had some examples. Subclassing
> > cx_Oracle.Connection and cx_Oracle.Cursor are the same as sublcassing
> > any other class in Python -- not very helpful if you haven't done much
> > of it yourself yet, I guess. :-)
>=20
> Well I have something like following:
>=20
> query =3D "insert into foobar (id, name) values (:1, :2)"
> values =3D {'1' : 123, '2' : 'Mr. Dumb'
> cursor.setinputsizes({'2' : cx_Oracle.CLOB})
> cursor.execute(query, values)
>=20
> But I'm getting error:
> Variable_TypeByPythonType(): unhandled data type
>=20
> What I'm doing wrong..?
Oracle uses :1, :2 for __positional__ arguments and :fred and :george
for __named__ arguments. cx_Oracle expects a dictionary for named
arguments and a sequence for positional arguments. So instead of
passing a dictionary as the arguments, pass a list instead and that
should solve your problems. In addition, setinputsizes() uses the
*args and **kwargs notation so you should specify the following:
cursor.setinputsizes([None, cx_Oracle.CLOB]) OR
cursor.setinputsizes(value =3D cx_Oracle.CLOB)
and reference :value in your statement. Make sense?
> -------------------------------------------------------
> 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
>
|