jangbagu / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Getting "DatabaseError" for all connections #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. import pypyodbc.
2. try to connect.

What is the expected output? What do you see instead?
A connection object.

What version of the product are you using? On what operating system?
pypyodbc-1.0.11 / python2.7.2 / linux

Please provide any additional information below.
Fresh install.  All I'm trying to do is start a connection.  See log attached.  
I get the same error with MS-SQL (Driver SQL Server Native Client 11.0) as well.

Original issue reported on code.google.com by cyborg10...@gmail.com on 1 Apr 2013 at 9:03

Attachments:

GoogleCodeExporter commented 8 years ago
Worth noting that this works fine with pyodbc

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 9:05

GoogleCodeExporter commented 8 years ago
Same result with latest from Git.

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 10:25

GoogleCodeExporter commented 8 years ago
Can you provide additional information, such as 64bit , 32bit information ?

Original comment by jiangwen...@gmail.com on 1 Apr 2013 at 10:50

GoogleCodeExporter commented 8 years ago
Yep, 64bit CentOS 6.1 with 64-bit Python 2.7.2.

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 10:52

GoogleCodeExporter commented 8 years ago
Also tried with 64-bit CentOS 6.3, RHEL 6.1 and Python 3.2.3.  All give the 
same error.

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 11:21

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Can you check what would be the output if you add ansi=False?
conn = pypyodbc.connect('DRIVER={MySQL ODBC 5.1 
Driver};SERVER=myserver;DATABASE=mydb;UID=user;PWD=password',ansi=False,ansi=Fal
se,unicode_results=Fase)

Original comment by jiangwen...@gmail.com on 1 Apr 2013 at 12:02

GoogleCodeExporter commented 8 years ago
Do you mean ansi=True?  False is default.  If I do =True, it connects ok, but 
then all my results come back encoded like:

u'\udc80\udc75\udc40\udc65'

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 12:02

GoogleCodeExporter commented 8 years ago
conn = pypyodbc.connect('DRIVER={MySQL ODBC 5.1 
Driver};SERVER=myserver;DATABASE=mydb;UID=user;PWD=password',ansi=False,unicode_
results=False)

Gives me the same error...

conn = pypyodbc.connect('DRIVER={MySQL ODBC 5.1 
Driver};SERVER=myserver;DATABASE=mydb;UID=user;PWD=password',ansi=True,unicode_r
esults=False)

Still gives me unicode results.

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 12:05

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
And if you try and print one of the unicode results:

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-3: 
ordinal not in range(256)

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 12:39

GoogleCodeExporter commented 8 years ago
I will install a CentOS 64bit and try that.

Original comment by jiangwen...@gmail.com on 1 Apr 2013 at 12:59

GoogleCodeExporter commented 8 years ago
Thanks!  Just so you get the same setup:

$ odbcinst --version
unixODBC 2.3.0

$ cat /etc/odbcinst.ini
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/libodbcpsql.so
FileUsage=1

[SQL Server Native Client 11.0]
Description=Microsoft SQL Server ODBC Driver V1.0 for Linux
Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=1

[MySQL ODBC 5.1 Driver]
Driver=/usr/lib64/libmyodbc5.so
UsageCount=2

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 1:57

GoogleCodeExporter commented 8 years ago
It works fine on my Ubuntu box at home, so might well be a CentOS / RHEL issue.

Original comment by cyborg10...@gmail.com on 1 Apr 2013 at 8:10

GoogleCodeExporter commented 8 years ago
is your ubuntu at home 64 bit?

Original comment by jiangwen...@gmail.com on 1 Apr 2013 at 11:18

GoogleCodeExporter commented 8 years ago
Yes

Original comment by cyborg10...@gmail.com on 2 Apr 2013 at 6:21

GoogleCodeExporter commented 8 years ago
Hi, Finally I'm not able to setup CentOS, so I would like to suggest two quick 
changes you can have a try.

First step:
-Open pypyodbc.py, text replace "if status == 0 and 'SQL_WCHART_CONVERT' in 
output:" to "if True:" .This will only make one change in Line 479.

Have a try.

Second step:
-If that doesn't work, text replace all "utf_16" to "utf_32" and all 
"utf_16_le" to "utf_32"

And then try again.

Hope that works.

Original comment by jiangwen...@gmail.com on 2 Apr 2013 at 12:10

GoogleCodeExporter commented 8 years ago
The fist test results in:
>>> import pypyodbc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/scratch/Python/lib/python2.7/site-packages/pypyodbc.py", line 518, in <module>
    raise OdbcLibraryError('Using narrow Python build with ODBC library '
pypyodbc.OdbcLibraryError: 'Using narrow Python build with ODBC library 
expecting wide unicode is not supported.'

And the second (with or without the first) results in the same issue as before.

Original comment by cyborg10...@gmail.com on 2 Apr 2013 at 12:59

GoogleCodeExporter commented 8 years ago
This works fine on the same box with 3.3.1, so it could be an issue with 2.7.2.

Original comment by cyborg10...@gmail.com on 15 May 2013 at 1:18

GoogleCodeExporter commented 8 years ago
2.7.4 has the same issue

Original comment by cyborg10...@gmail.com on 15 May 2013 at 1:39

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 3 Sep 2013 at 11:35