- changed status to wontfix
oracle unicode
Issue #421
resolved
This test programms fails on all codecs.
#!/usr/bin/env python2.5
# -*- coding: utf-8 -*-
from sqlalchemy import *
oracle = 'oracle://user:pass@oracle'
def do_test(uri, dbname, encoding):
table = Table('testtable', BoundMetaData(uri, encoding=encoding),
Column('testtable_id', Integer, Sequence('testable_seq'), primary_key=True),
Column('name', Unicode(20)),
)
value = u'Künstler'
table.drop(checkfirst=True)
table.create(checkfirst=True)
table.insert().execute(name=value)
name = table.select().execute().fetchone().name
if name == value:
print '%10s [PASS](PASS)' % dbname
else:
print '%10s [FAIL](FAIL)' % dbname
table.drop(checkfirst=True)
do_test(oracle, 'oracle', 'utf-8')
do_test(oracle, 'oracle', 'utf-16')
do_test(oracle, 'oracle', 'latin-1')
However on the same database I can store latin-1 characters via sql developer. I can also insert them manually into the database (if I use a String column) like:
table.engine.execute("insert into testtable (testtable_id, name) values (1, '%s')" % u'Künstler'.encode('latin-1'))
I see the characters truthfully reflected in sql developer. But I cannot retrieve it out again.
I'm not sure this is sqlalchemys problem, I suspect the culprit here is cx_Oracle or my DBA inexpirience (the lack thereof).
Comments (1)
-
repo owner - Log in to comment
"utf-8" and "latin-1" pass for me. "utf-16" first gave an ORA-1406, then i increased the column size and got "UnicodeDecodeError: 'utf16' codec can't decode byte 0x00 in position 22: truncated data". this is because an oracle database is created with a specific encoding, such as utf-8, of which latin-1 and ascii can fit inside of. you might want to check what encoding your oracle database was set up with.