title: ASCII error when fetching results from database with pyodbc and sql server 2005
body: <p>I have this error when fetching results from the database. </p>
  
  <p><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 3: ordinal not in range(128)</code></p>
  
  <p>Upon closer inspection, I found out that several of the records have ñ and Ñ in them. And I cannot just replace them or ignore them because my db are records for personal information and cannot be changed. I have read many links regarding this and most of it says that I have to replace them or remove them. I have also tried using what's <a href="https://docs.python.org/2/howto/unicode.html" rel="nofollow noreferrer">in here</a> but it's not applicable when database is involve. Also, I tried this <a href="http://blog.webforefront.com/archives/2011/02/python_ascii_co.html" rel="nofollow noreferrer">one</a>, and this <a href="https://stackoverflow.com/a/1701378/4652234">one</a> but nothing seems to answer my problem. I am formatting the fetched results like this:</p>
  
  <pre><code>cursor.execute("select * from dummy")
  str1=''
  for row in cursor:
      str1 = str1 + ''.join(map(str,row)) + "\n" 
  print str1
  </code></pre>
  
  <p>and it outputs the error above.
  However, when I try this one:</p>
  
  <pre><code>for row in cursor:
      str1 = str(row)
      print str1.decode('latin-1')
  </code></pre>
  
  <p>It display NO errors but the results were:</p>
  
  <pre><code>(u'Ara\xf1as    ', )
  (u'Para\xf1aque ', )
  (u'Ma\xf1a\xf1a    ', )
  (u'Di\xd1a      ', )
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>Arañas
  Parañaque
  Mañaña
  DiÑa
  </code></pre>
  
  <p>How can I solve this ascii error? </p>