title: Pandas UnicodeDecodeError while using read_sql
body: <p>I am trying to execute SQL queries using pandas.read_sql. It usually works, but for <strong>certain</strong> queries I run into this error:</p>
  
  <pre><code>  File "C:\Anaconda3\lib\site-packages\pandas\io\sql.py", line 1454, in _fetchall_as_list
      result = cur.fetchall()
  
      UnicodeDecodeError: 'ascii' codec can't decode byte 0xb4 in position 3: ordinal not in range(128)
  </code></pre>
  
  <p>I tried solutions suggested for a very similar problem here (<a href="https://stackoverflow.com/questions/40231498/unicodedecodeerror-with-pandas-read-sql">UnicodeDecodeError with pandas.read_sql</a>) but it didn't resolve the issue. </p>
  
  <p>I am using cx_oracle library for the database connection.</p>
  
  <p>I tried</p>
  
  <pre><code>db = cx_Oracle.connect(user,pwd, dsn_dict[dbname],encoding='utf-8')
  </code></pre>
  
  <p>but when I check the encoding using</p>
  
  <pre><code>print(db.encoding)
  print(db.nencoding)
  </code></pre>
  
  <p>I always get</p>
  
  <pre><code>ASCII
  ASCII
  </code></pre>
  
  <p>I tried changing NLS_LANG using </p>
  
  <pre><code>os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.US7ASCII'
  </code></pre>
  
  <p>but it results in the same error</p>
  
  <p>These are the database NLS parameters:</p>
  
  <pre><code>NLS_CHARACTERSET    US7ASCII
  
  NLS_NCHAR_CHARACTERSET  AL16UTF16
  </code></pre>
  
  <p>I ran the same query in access and I notice this character in the query result, which might be causing this issue:</p>
  
  <pre><code>¿
  </code></pre>
  
  <p>Basically, I don't know how to set proper encoding to deal with the problem. Any help is appreciated. Thank you.</p>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>For reference, I solved this by setting</p>
  
  <pre><code>os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
  </code></pre>
  
  <p>I dont like doing this though. better solutions are appreciated.</p>