Monday, October 27, 2014

Re: TypeError: can't concat bytes to tuple

Well, this is not a Django-related question, but still.

The tutorial you are following uses Python 2.5.1, which differs a lot from the Python 3.4 that you are using. If you want to still follow that tutorial you'd better install Python 2.7, which is more compatible with 2.5

Also, try printing the query (the sql variable in your case) before executing it in mysql and check if it is right (in particular that it is actually a string and not a list, tuple, or something else)

Regards!



On Mon, Oct 27, 2014 at 8:29 PM, Adarsh Sharma <eddy.adarsh@gmail.com> wrote:
Hi all,

I am running below program : http://palewi.re/posts/2008/04/26/python-recipe-connect-to-mysql-database-execute-a-query-print-the-results/

on Centos 6.4 , Python 3.4 but not sure why it is failing with below exception :

root@db2 bin]# python printfields_new.py datbase1 tb_sime_darby
Wikified HTML for adunit.tb_sime_darby
========================
Traceback (most recent call last):
  File "printfields_new.py", line 33, in <module>
    PrintFields(users_database, users_table)
  File "printfields_new.py", line 12, in PrintFields
    mysql.execute(sql)
  File "/usr/local/lib/python3.4/site-packages/pymysql/cursors.py", line 132, in execute
    result = self._query(query)
  File "/usr/local/lib/python3.4/site-packages/pymysql/cursors.py", line 271, in _query
    conn.query(q)
  File "/usr/local/lib/python3.4/site-packages/pymysql/connections.py", line 725, in query
    self._execute_command(COM_QUERY, sql)
  File "/usr/local/lib/python3.4/site-packages/pymysql/connections.py", line 888, in _execute_command
    self._write_bytes(prelude + sql[:chunk_size-1])
TypeError: can't concat bytes to tuple

Anyone has any idea about this ? Also , how can we make sure to prevent from Identation erros in python ?

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54bfc5a3-1336-4c26-ad49-8af2a2da4ab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei1Kw3Ycaf_QbwCDU_QNrjZZtqfcfTuuv%2Bs5h-9FPgzZPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment