This discussion is archived
1 Reply Latest reply: Jun 23, 2009 9:31 AM by cj RSS

insert characterset problems

696834 Newbie
Currently Being Moderated

I am running a script that reads data from a local text file, parses it, and then do an INSERT with the parsed values.

The inserts run ok.

But, when I retrieve the values from the database I see strange characters instead of our Norwegian characters æ,ø,å.

Some info:
- The NLS_CHARACTERSET in the database is AL32UTF8.
- The database is Oracle XE 10.
- The OS is CentOS 5.3
- The file is saved as UTF in the Gedit Gnome editor.
- I open the file with open('filename.txt')
- Read all lines into a list with readlines()
- I parse all lines using [from:to] string splitting notation.
- And add to the INSERT using "INSERT into mytable values (%d, %s)" % (int(pn), ps).

I also print out the INSERT string just to make sure everything looks ok and it does, but when inside the database the characters æøå are weird.


Edited by: user10719935 on Jun 12, 2009 12:51 AM
  • 1. Re: insert characterset problems
    cj Employee ACE
    Currently Being Moderated
    Oracle allows the database client (e.g. Python) character set to be different to the database character set. Oracle libraries will attempt to map data between the two character sets. If the mapping isn't possible, then characters will often appear as question marks.

    Set the character set used for the client with the environment variable NLS_LANG.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points