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

Getting TypeError when connecting to MySQL db #63

Open
GoogleCodeExporter opened this issue Dec 21, 2015 · 1 comment
Open

Getting TypeError when connecting to MySQL db #63

GoogleCodeExporter opened this issue Dec 21, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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

@Sreekhar
Copy link

I've the same exact issue. The code works well in Windows environment but not on Ubuntu. Any progress on this issue?

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

No branches or pull requests

2 participants