Re: [cx-oracle-users] Problems with UTF8 and unicode version of cx_Oracle
Brought to you by:
atuining
From: Stefan D. <ste...@de...> - 2010-07-08 09:21:37
|
Hi, swapped module again (unicode to normal version of cx_Oracle) and now finally I can insert special characters. I used bind variables in other parts of my python script, but not always. If I had known this > Oracle always considers SQL statements as strings (= VARCHAR), earlier... >_< Thank you very much! Regards, Stefan > Even if the column is defined as NVARCHAR2, you pass it in the SQL > statement as a string literal. > > Oracle always considers SQL statements as strings (= VARCHAR), > so the special character will be lost if it cannot be encoded in the > NLS_CHAR_CHARACTERSET. > > You should not pass the values as string literals in the query, but > use bind variables instead: > cursor.execute("INSERT INTO conf (CID, title) VALUES (4, :1)", [title]) > Now the query only contains plain ascii characters; the unicode value is passed > through a bind variable which will respect all characters. > |