2012-02-29 12 views
0

Windows 2k3 x64でpymssql 1.9.908を使用する際に問題が発生しています。 以下のコードを使って簡単なクエリをテストしました。しかし、私はこのエラーが発生します:照会時のpymssql 1.9.908エラー

Traceback (most recent call last): 
    File "<pyshell#5>", line 1, in <module> 
    cur.execute('SELECT * from tbl_staticDetails') 
    File "pymssql.pyx", line 296, in pymssql.Cursor.execute (pymssql.c:3246) 
OperationalError: SQL Server message 4004, severity 16, state 1, line 1: 
Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. 
DB-Lib error message 4004, severity 16: 
General SQL Server error: Check messages from the SQL Server 

ここIDLEで入力された私のサンプルコードです:

>>> import pymssql 
>>> conn = pymssql.connect(host='<IP reachable by my machine>', user='sa', password='<password>', database='<database nbame>') 
>>> cur = conn.cursor() 
>>> cur.execute('SELECT * from tbl_staticDetails') 

は、任意のアイデアは大歓迎されています。 ありがとう!

答えて

0

http://pymssql.sourceforge.net/faq.phpを参照してください:

In SQL 2000 SP4 or newer, SQL 2005 or SQL 2008, if you do a query that returns NTEXT type data, you may encounter the following exception: _mssql.MssqlDatabaseError: SQL Server message 4004, severity 16, state 1, line 1: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

It means that SQL Server is unable to send Unicode data to pymssql, because of shortcomings of DB-Library for C. You have to CAST or CONVERT the data to equivalent NVARCHAR data type, which does not exhibit this behaviour.

+0

ので、私はちょうど私のテーブルのCHARフィールドのデータ型を作ることができ、それが動作しますか?ありがとうございました – jaysonpryde