Skip to content

Not support unicode sql statement in Chinese #206

@vincentwyshan

Description

@vincentwyshan

SOURCE CODE:

# coding=utf8

import pyodbc

print pyodbc.version

sql = u"""SELECT
    N'我的' AS [Name]
"""


def test_success():
    conn = pyodbc.connect(u'Driver={SQL Server};Server=localhost;Database=mydb;Trusted_Connection=yes;',
        unicode_results=True)
    cursor = conn.cursor()

    cursor.execute(sql)
    print "test_success::"
    print "." * 80
    # data = cursor.fetchall()
    print "." * 80


test_success()

Got errors:

PS C:\Users\vincent\Documents\GitHub> python C:\Users\vincent\Downloads\pyodbctest.py
4.0.13
test_success::
................................................................................
................................................................................
Exception UnicodeEncodeError: UnicodeEncodeError('ascii', u"SELECT\n    N'\u6211\u7684' AS [Name]\n", 13, 15, 'ordinal not in range(128)') in <module 'threading' from 'C:\Python27\lib\threading.pyc'> ignored

Does anyone knows is it a bug or I just wrote wrong code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions