ketan27j / pypyodbc

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

Getting TypeError when connecting to MySQL db #63

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. mysql  Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using 
readline 6.3 / Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-45-generic x86_64)

# -*- coding: UTF-8 -*-
import pypyodbc as db
cnxn = 
db.connect("DRIVER={UnixODBC};CHARSET=UTF8;SERVER=xxx.xxx.0.xxx;PORT=3306;DATABA
SE=GRW;UID=xxx;PWD=xxx")
cursor = cnxn.cursor()
cursor.execute("SELECT city_id,nid,html_content,notes FROM content_city WHERE 
nid = 3.0 ORDER BY city_id LIMIT 10;")
rs = cursor.fetchall()

for r in rs:
    print( 'city_id:', row[0] )        # access by column index

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

Traceback (most recent call last):
  File "temp.py", line 10, in <module>
    rs = cursor.fetchall()
  File "/usr/local/lib/python3.4/dist-packages/pypyodbc.py", line 1819, in fetchall

    row = self.fetchone()
  File "/usr/local/lib/python3.4/dist-packages/pypyodbc.py", line 1898, in fetchone

    raw_value = ''.join(raw_data_parts)
TypeError: sequence item 0: expected str instance, bytes found
administrator@roy-dev:/var/www/fossil/fossil/python$ python3.4 temp.py
Traceback (most recent call last):
  File "temp.py", line 10, in <module>
    rs = cursor.fetchall()
  File "/usr/local/lib/python3.4/dist-packages/pypyodbc.py", line 1819, in fetchall

    row = self.fetchone()
  File "/usr/local/lib/python3.4/dist-packages/pypyodbc.py", line 1898, in fetchone

    raw_value = ''.join(raw_data_parts)
TypeError: sequence item 0: expected str instance, bytes found

What version of the product are you using? On what operating system?
Python 3.4 / pypyodbc 1.3.3

Please provide any additional information below.
Works when I try it with Python 2.7. 

Original issue reported on code.google.com by royh...@gmail.com on 17 Mar 2015 at 12:11