String encoding not working right with freetds and unixodbc. What excoding in pyodbc expecting from odbc?

63 views
Skip to first unread message

Matthew Denson

unread,
Dec 11, 2012, 6:09:10 PM12/11/12
to pyo...@googlegroups.com
Hi,

I am struggling to get strings out of a TEXT field in SQL Server 2008 R2.

When I try:

        c.execute("select id, name from recipe where id = 4140567")
    
        row = c.fetchone()
        if row:
            print row

the output is:

    (Decimal('4140567'), u'\U0072006f\U006e0061\U00650067')

Alternatively, if I try:

    print "{0}, '{1}'".format(row.id, row.name)

Then the result is:

    Traceback (most recent call last):
      File "/home/mdenson/projects/test.py", line 20, in <module>
        print "{0}, '{1}'".format(row.id, row.name)
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

I'm in Ubuntu 12.04, python 2.7.3, and compiled the latest pyodbc 3.0.7-beta06.


Thanks for your help.
Matthew
Reply all
Reply to author
Forward
0 new messages