My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 153 attachment: issue.txt (4.8 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

Environment:
- Linux Ubuntu 10.04
- python 2.6 - package from distro
- FreeTDS compiled from snapshot freetds-0.92.dev.20110811 (but no matter - same results using package from distro)
- unixODBC 2.3.0 compiled from source (but no matter - same results using package from distro)
- pyodbc 2.1.9
- django-pyodbc current from svn
- MSSQL 2008R2 Express on Windows 7 64 bit
My database settings:
- collation - Polish_CI_AS
- strings stored in database coded in windows-1250


pure tsql:
===========

pawel@dell:~$ tsql -S MyDSN -U MyUID
locale is "pl_PL.utf8"
locale charset is "UTF-8"
Password:
1> use MyDBName
2> go
1> select top 2 nazwa from towary order by towarid
2> go
nazwa
Sprężyny zawieszenia przód Def/Disco/RR +2''(para)
Sprężyny zawieszenia tył Def/Disco/RR +2'' (para)
(2 rows affected)
1> exit

Result is OK, unicode characters displayed correctly

isql:
==============

pawel@dell:~$ isql -v MyDSN MyUID MyPWD
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select top 2 nazwa from towary order by towarid
+-----------------------
nazwa +-----------------------
Sprężyny zawieszenia przód Def/Disco/RR +2'' (para)
Sprężyny zawieszenia tył Def/Disco/RR +2'' (para)
+-----------------------
SQLRowCount returns 2
2 rows fetched
SQL>

Result is OK, unicode characters displayed correctly


pyodbc:
=============

pawel@dell:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> connection=pyodbc.connect(r'DRIVER={MyDriver};SERVER=MyServer;DATABASE=MyDB;UID=MyUID;PWD=MyPWD')
>>> cur=connection.cursor()
>>> cur.execute("select top 2 nazwa from towary order by towarid")
<pyodbc.Cursor object at 0x2324690>
>>> n0=cur.fetchone().nazwa
>>> print n0
Spr��yny zawieszenia prz�d Def/Disco/RR +2''(para)
>>> n1=cur.fetchone().nazwa
>>> print n1
Spr��yny zawieszenia ty� Def/Disco/RR +2'' (para)
>>> print n0.decode("windows-1250")
Sprężyny zawieszenia przód Def/Disco/RR +2''(para)
>>> print n1.decode("windows-1250")
Sprężyny zawieszenia tył Def/Disco/RR +2'' (para)
>>>


OK




django-pyodbc - unicode_results set to False in settings.py:
=============================================================


pawel@dell:~/work/djproject/test$ python manage.py shell
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> cur=connection.cursor()
>>> cur.execute("select top 2 nazwa from cdn.towary order by towarid")
<pyodbc.Cursor object at 0x3399570>
>>> n0=cur.fetchone()[0]
>>> n0
u"Spr??yny zawieszenia prz?d Def/Disco/RR +2''(para)"
>>> print n0
Spr??yny zawieszenia prz?d Def/Disco/RR +2''(para)
>>> print n0.decode("windows-1250")
Spr??yny zawieszenia prz?d Def/Disco/RR +2''(para)
>>> n1=cur.fetchone()[0]
>>> n1
u"Spr??yny zawieszenia ty? Def/Disco/RR +2'' (para)"
>>> print n1
Spr??yny zawieszenia ty? Def/Disco/RR +2'' (para)
>>> print n1.decode("windows-1250")
Spr??yny zawieszenia ty? Def/Disco/RR +2'' (para)
>>>




django-pyodbc - unicode_results set to True in settings.py:
============================================================

pawel@dell:~/work/djproject/test$ python manage.py shell
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> cur=connection.cursor()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/base.py", line 239, in _cursor
if self.ops.sql_server_ver < 2005:
File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/operations.py", line 22, in _get_sql_server_ver
ver_code = int(cur.fetchone()[0].split('.')[0])
File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/base.py", line 349, in fetchone
row = self.cursor.fetchone()
Error: ('HY003', '[HY003] [FreeTDS][SQL Server]Program type out of range (0) (SQLGetData)')
>>>

Powered by Google Project Hosting