zmeng3 / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Python3.3.2 + pyodbc in Ubuntu 13.10 does not work #381

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Installed: python, python-dev, python3, python3-dev, g++, gcc, unixODBC, 
unixODBC-dev

2. Follow the steps in https://code.google.com/p/pyodbc/wiki/Building
  a. python setup.py build
  b. sudo python setup.py install

3. Try to exec a query:

$ python
Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> pyodbc.version
'3.0.7'
>>> con = 
pyodbc.connect("DRIVER={NetezzaSQL};SERVERNAME=1.1.1.1;PORT=5480;DATABASE=dbname
;USERNAME=user;PASSWORD=pass")
>>> cursor = con.cursor()
>>> cursor.execute('SELECT MAX(CONNECT_TIME) FROM V_CONNECTION')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.ProgrammingError: ('42000', '[42000] ERROR:  \'S\'\nerror    ^ found "S" 
(at char 1) expecting a keyword (27) (SQLExecDirectW)')

What is the expected output? What do you see instead?

Expected output: query results (it works on Windows with python3+pyodbc and in 
this same Ubuntu server using python2.7+pyodbc).

However, it shows the following error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.ProgrammingError: ('42000', '[42000] ERROR:  \'S\'\nerror    ^ found "S" 
(at char 1) expecting a keyword (27) (SQLExecDirectW)')

What version of the product are you using? On what operating system?

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 13.10
Release:        13.10
Codename:       saucy

$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 18 ago 26 10:05 /usr/bin/python -> /usr/bin/python3.3

$ python -V
Python 3.3.2+

$ python
Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> pyodbc.version
'3.0.7'

Original issue reported on code.google.com by a.navarr...@gmail.com on 26 Aug 2014 at 8:36

GoogleCodeExporter commented 8 years ago
This is the result of the build, perhaps it is useful.

~/pyodbc-3.0.7$ sudo python setup.py build
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.3
creating build/temp.linux-x86_64-3.3/datos
creating build/temp.linux-x86_64-3.3/datos/usuarios
creating build/temp.linux-x86_64-3.3/home/user
creating build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7
creating build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/pyodbcmodule.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbcmodule.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/buffer.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/buffer.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/connection.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/connection.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
/home/user/pyodbc-3.0.7/src/connection.cpp: In function ‘PyObject* 
Connection_getinfo(PyObject*, PyObject*)’:
/home/user/pyodbc-3.0.7/src/connection.cpp:600:40: warning: dereferencing 
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         SQLUINTEGER n = *(SQLUINTEGER*)szBuffer; // Does this work on PPC or do we need a union?
                                        ^
/home/user/pyodbc-3.0.7/src/connection.cpp:613:49: warning: dereferencing 
type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         result = PyInt_FromLong(*(SQLUSMALLINT*)szBuffer);
                                                 ^
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/row.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/row.o -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/cursor.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/cursor.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/params.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/params.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/sqlwchar.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/sqlwchar.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/cnxninfo.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/cnxninfo.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/getdata.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/getdata.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/pyodbcdbg.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbcdbg.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/pyodbccompat.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbccompat.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python3.3m -c 
/home/user/pyodbc-3.0.7/src/errors.cpp -o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/errors.o 
-Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for 
C/ObjC but not for C++ [enabled by default]
creating build/lib.linux-x86_64-3.3
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions 
-Wl,-Bsymbolic-functions -Wl,-z,relro -Wno-unused-result -DNDEBUG -g -fwrapv 
-O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 
-Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -g 
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-D_FORTIFY_SOURCE=2 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbcmodule.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/buffer.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/connection.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/row.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/cursor.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/params.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/sqlwchar.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/cnxninfo.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/getdata.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbcdbg.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/pyodbccompat.o 
build/temp.linux-x86_64-3.3/home/user/pyodbc-3.0.7/src/errors.o -lodbc -o 
build/lib.linux-x86_64-3.3/pyodbc.cpython-33m.so

~/pyodbc-3.0.7$ sudo python setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.linux-x86_64-3.3/pyodbc.cpython-33m.so -> 
/usr/local/lib/python3.3/dist-packages
running install_egg_info
Removing /usr/local/lib/python3.3/dist-packages/pyodbc-3.0.7.egg-info
Writing /usr/local/lib/python3.3/dist-packages/pyodbc-3.0.7.egg-info

Thanks!

Original comment by a.navarr...@gmail.com on 26 Aug 2014 at 8:46

GoogleCodeExporter commented 8 years ago
Same issue on Ubuntu 15.4 with Python 3.4 and latest PyODBC.

Same code works on windows under python 3.2.

Original comment by tswor...@gmail.com on 26 Apr 2015 at 5:39

GoogleCodeExporter commented 8 years ago
wanted to follow up. In my case the ODBC driver (NetezzaSQL) was set to use 
UTF8. I first though the issue was either a UC2 or UC4 build of Python. Both 
made no difference. Switching the driver to UTF16 
(UnicodeTranslationOption=utf16) fixed the issue for me.

Original comment by tswor...@gmail.com on 26 Apr 2015 at 6:42