pypyodbc
pypyodbc copied to clipboard
All text is Japanese
I'm getting wrong Japanese text (or maybe a wrong character set) when trying to connect to northwind.mdb
. I created a Python script called test_access.py
:
# -*- coding: utf-8 -*-
import pypyodbc
c = pypyodbc.connect('Driver={MDBTools};DBQ=northwind.mdb;Charset=utf-8')
x = c.cursor()
x.execute('select * from Shippers')
r = x.fetchone()
print(r)
Calling it with python test_access.py
results in:
(1, '灓敥祤䔠灸敲獳', '㔨㌰\u2029㔵ⴵ㠹ㄳ')
However, I can see correct data using mdb-sql
:
echo "select * from Shippers" | mdb-sql northwind.mdb
And the result is:
+-----------+--------------------------------------------------------------------------------+------------------------------------------------+
|ShipperID |CompanyName |Phone
|
+-----------+--------------------------------------------------------------------------------+------------------------------------------------+
|1 |Speedy Express |(503) 555-9831 |
|2 |United Package |(503) 555-3199 |
|3 |Federal Shipping |(503) 555-9931 |
+-----------+--------------------------------------------------------------------------------+------------------------------------------------+
3 Rows retrieved
Same "Japanese" symbols in cursor.description column name with Connection(... unicode_results=False). Version 1.3.5. But work fine with 1.3.3.1. DB - Intersystems Cache 5.0
Tested on linux x64
$ pacman -Qi mdbtools
Name : mdbtools
Version : 0.7.1-1
$ pip freeze | grep pypyodbc
pypyodbc==1.3.4
Test snippet:
from __future__ import print_function
import pypyodbc
for unicode_results in (True, False):
conn = pypyodbc.connect("DSN=test", unicode_results=unicode_results)
curs = conn.cursor()
for t in curs.tables():
print(curs.description)
print(t)
break
conn.close()
print()
Python 2.7.14:
[(u'table_cat', <type 'str'>, 128, 128L, 128L, 0, True), (u'table_schem', <type 'str'>, 128, 128L, 128L, 0, True), (u'table_name', <type 'str'>, 128, 128L, 128L, 0, True), (u'table_type', <type 'str'>, 128, 128L, 128L, 0, True), (u'remarks', <type 'str'>, 254, 254L, 254L, 0, True)]
('', '', u'\u534d\u7379\u624f\u656a\u7463s', u'\u5953\u5453\u4d45\u5420\u4241\u454c', '')
[(u'\u4154\u4c42\u5f45\u4143t', <type 'str'>, 128, 128L, 128L, 0, True), (u'\u4154\u4c42\u5f45\u4353\u4548m', <type 'str'>, 128, 128L, 128L, 0, True), (u'\u4154\u4c42\u5f45\u414e\u454d', <type 'str'>, 128, 128L, 128L, 0, True), (u'\u4154\u4c42\u5f45\u5954\u4550', <type 'str'>, 128, 128L, 128L, 0, True), (u'\u4552\u414d\u4b52s\u4550', <type 'str'>, 254, 254L, 254L, 0, True)]
(None, None, 'MSysObjects', 'SYSTEM TABLE', None)
Python 3.6.4:
[('table_cat', <class 'str'>, 128, 128, 128, 0, True), ('table_schem', <class 'str'>, 128, 128, 128, 0, True), ('table_name', <class 'str'>, 128, 128, 128, 0, True), ('table_type', <class 'str'>, 128, 128, 128, 0, True), ('remarks', <class 'str'>, 254, 254, 254, 0, True)]
('', '', '卍獹扏敪瑣s', '奓呓䵅吠䉁䕌', '')
[('䅔䱂彅䅃t', <class 'str'>, 128, 128, 128, 0, True), ('䅔䱂彅䍓䕈m', <class 'str'>, 128, 128, 128, 0, True), ('䅔䱂彅䅎䕍', <class 'str'>, 128, 128, 128, 0, True), ('䅔䱂彅奔䕐', <class 'str'>, 128, 128, 128, 0, True), ('䕒䅍䭒s䕐', <class 'str'>, 254, 254, 254, 0, True)]
(b'', b'', b'MSysObjects', b'SYSTEM TABLE', b'')
This should be related to #25 too