[cx-oracle-users] Question concerning executemany() in cx_Oracle
Brought to you by:
atuining
From: matilda m. <ma...@gr...> - 2007-02-06 17:26:41
|
Hi all, hi Anthony, while testing some unicode and encoding related stuff (yes Anthony, I work on that. ;-) ) I struggled over the following code: --------------8<-------------------------------- #!/usr/bin/python # -*- coding: utf8 -*- import sys import os import cx_Oracle as dbi utf8 =3D 'GERMAN_GERMANY.UTF8' latin1 =3D 'GERMAN_GERMANY.WE8ISO8859P1' if __name__ =3D=3D '__main__': os.environ['NLS_LANG'] =3D latin1 con =3D dbi.connect('scott/tiger@twws') cur =3D con.cursor() a =3D u'=C3=84' * 4000 u =3D u'=C3=9C' * 4000 o =3D u'=C3=96' * 4000 ae =3D a.encode('latin1') ue =3D u.encode('latin1') oe =3D o.encode('latin1') print "Length ae:", len(ae) print "Length ue:", len(ue) print "Length oe:", len(oe) list =3D ( (ae,), (ue,), (oe,) ) print type(list) con.begin() cur.executemany('insert into tst values (:val)', list) con.commit() cur.close() con.close() --------------8<-------------------------------- Running this code gives me an ugly exception: Traceback (most recent call last): File "./i.py", line 26, in ? cur.executemany('insert into tst values (:val)', list) TypeError: argument 2 must be list, not tuple I'm surprised: A tuple is a sequence and PEP249 (http://www.python.org/dev/peps/pep-0249/) says: "[...] execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.[..]" So, what am I missing: Please enlight me. :-)) Best regards Andreas Mock |