Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All text is Japanese #54

Open
wind39 opened this issue Apr 17, 2017 · 2 comments
Open

All text is Japanese #54

wind39 opened this issue Apr 17, 2017 · 2 comments

Comments

@wind39
Copy link

wind39 commented Apr 17, 2017

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
@Stolb27
Copy link

Stolb27 commented May 17, 2017

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

@pmav99
Copy link

pmav99 commented Feb 24, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants