title: Writing accented characters to Oracle
body: <p>I have to update an existing script so that it writes some data to an Oracle 10g database.  The script and the database both run on the same Solaris 10 (Intel) machine.  Python is v2.4.4.</p>
  
  <p>I'm using cx_Oracle and can read/write to the database with no problem.  But the data I'm writing contains accented characters which are not getting written correctly.  The accented character turns into an upside-down question mark.</p>
  
  <p>The value is read from a binary file with this code, in :</p>
  
  <pre><code>class CustomerHeaderRecord:
      def __init__( self, rec, debug = False ):
          self.record = rec
          self.acct   = rec[ 84:104 ]
  </code></pre>
  
  <p>And the contents of the <code>acct</code> variable displays on-screen correctly.</p>
  
  <p>Below is the code that writes to the db (the <code>acct</code> value is passed in as the <code>val_1</code> variable):</p>
  
  <pre><code>class MQ:
      def __init__( self, rec, debug = False ):
          self.customer_record = CustomerHeaderRecord( rec, debug )
          self.add_record(self.customer_record.acct, self.cm_custid)
  
      def add_record(self, val_1, val_2):
          cur = conn.cursor()
          qry = "select count(*) from table_name where value1 = :val1"
          cur.execute(qry, {'val1':val_1})
          count = cur.fetchone()
          if count[0] == 0:
              cur = conn.cursor()
              qry = "insert into table_name (value1, value2) values(:val1, :val2)"
              cur.execute(qry, {'val1':val_1, 'val2':val_2})
              conn.commit()
  </code></pre>
  
  <p>The <code>acct</code> value doesn't make it to the database correctly.  I've googled a bunch of stuff about unicode and UTF-8 but haven't found anything that helps me yet.  In the database, the NLS_LANGUAGE is 'American' and the NLS_CHARACTERSET is 'AL32UTF8'.  </p>
  
  <p>Do I need to 'do something' to/with the <code>acct</code> variable before/during the insert?</p>