Re: [cx-oracle-users] Unicode support
Brought to you by:
atuining
|
From: Sébastien S. <sa...@us...> - 2008-10-02 13:23:40
|
Hi Anthony,
thank you for this evolution of cx_Oracle!
It tested it and it seems to work fine for output, however when doing
some input I always get the same kind of error:
$ python test_oracle.py
Traceback (most recent call last):
File "test_oracle.py", line 18, in <module>
cursor.execute('insert into personne values(:0, :1)', [u'abc', u'def'])
cx_Oracle.DatabaseError: ORA-24363: measurements in characters illegal here
Here is the trivial test I ran:
import cx_Oracle
def OutputTypeHandler(cursor, name, defaultType, size, precision, scale):
if defaultType in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR):
return cursor.var(unicode, size, cursor.arraysize)
connection = cx_Oracle.Connection('SSA_UTF8/sungard@UTF102NP')
connection.outputtypehandler = OutputTypeHandler
cursor = connection.cursor()
try:
cursor.execute('drop table personne')
except cx_Oracle.DatabaseError:
pass
cursor.execute('create table personne (name nchar(4), first_name nchar(6))')
cursor.execute('insert into personne values(:0, :1)', [u'abc', u'def'])
cursor.execute("select * from personne")
for row in cursor:
print "Row:", row
Is there something to configure in order to allow unicode strings input?
Thanks in advance
--
Sébastien Sablé
Anthony Tuininga a écrit :
> All,
>
> I just checked in to Subversion support for Unicode. Thanks go to
> Amaury Forgeot d'Arc for the patch he provided earlier this year and
> to everyone else for their patience. :-) Since I have little
> experience with languages other than English and I only have access to
> little endian machines I'd appreciate those of you with such
> experience or machines to test the new code for me and let me know the
> results.
>
> Note that now nchar, nvarchar2 data are now returned as unicode. It is
> also possible to bind unicode strings in to cursors. SQL statements
> and varchar2 and char data are still returned as encoded strings. Note
> that with another new feature in cx_Oracle you can force all strings
> to be returned as unicode if you so desire. Below is an example that
> will run with the data in the test suite:
>
> import cx_Oracle
>
> def OutputTypeHandler(cursor, name, defaultType, size, precision, scale):
> if defaultType in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR):
> return cursor.var(unicode, size, cursor.arraysize)
>
> connection = cx_Oracle.Connection("cx_Oracle/dev@eadev")
> connection.outputtypehandler = OutputTypeHandler
> cursor = connection.cursor()
> cursor.execute("select * from teststrings")
> for row in cursor:
> print "Row:", row
>
> If you have questions, let me know. If you have feedback, please
> provide it. Thanks.
>
> Anthony
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> cx-oracle-users mailing list
> cx-...@li...
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
|