Problem with pymysql + python 2.7
See original GitHub issueCame across this problem when running a full test suite using pymysql
with Python 2.7
.
If you attempt to pass in a binary to BlobField
, it results in the following error upon execution.
build/bdist.linux-x86_64/egg/peewee.py:4494: in create
???
build/bdist.linux-x86_64/egg/peewee.py:4680: in save
???
build/bdist.linux-x86_64/egg/peewee.py:3213: in execute
???
build/bdist.linux-x86_64/egg/peewee.py:2628: in _execute
???
build/bdist.linux-x86_64/egg/peewee.py:3454: in execute_sql
???
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:156: in execute
query = self.mogrify(query, args)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:135: in mogrify
query = query % self._escape_args(args, conn)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:110: in _escape_args
return tuple(conn.escape(arg) for arg in args)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:110: in <genexpr>
return tuple(conn.escape(arg) for arg in args)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/connections.py:781: in escape
return escape_item(obj, self.charset, mapping=mapping)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:26: in escape_item
val = encoder(val, mapping)
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:109: in escape_unicode
return u"'%s'" % _escape_unicode(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = <read-only buffer for 0x7f4027d59880, size -1, offset 0 at 0x7f4027d653f0>, mapping = None
def _escape_unicode(value, mapping=None):
"""escapes *value* without adding quote.
Value should be unicode
"""
> return value.translate(_escape_table)
E AttributeError: 'buffer' object has no attribute 'translate'
mapping = None
value = <read-only buffer for 0x7f4027d59880, size -1, offset 0 at 0x7f4027d653f0>
.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:72: AttributeError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /vagrant/peewee-extras/.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py(72)_escape_unicode()
-> return value.translate(_escape_table)
Code to reproduce the problem;
class TestModel(Model):
value = BlobField()
v = binascii.unhexlify('0a0a0a')
OrderedUUIDModel.create(value=str(v))
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
"pip install pymysql" syntax error for python 2.7.13
You first have to go into the folder where pip.exe is present. In windows, it is in Scripts folder: cd C:\Python27\Scripts pip install ......
Read more >ModuleNotFoundError: No module named 'pymysql' in Python
The Python "ModuleNotFoundError: No module named 'pymysql'" occurs when we forget to install the PyMySQL module before importing it or install ...
Read more >Error provisioning after update to Trellis: The PyMySQL ...
Error provisioning after update to Trellis: The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.
Read more >10.12.2 errors.Error Exception - MySQL :: Developer Zone
This exception is the base class for all other exceptions in the errors module. It can be used to catch all errors in...
Read more >Install MySQL Connector Python on Windows, MAC, Linux, Unix
In this lesson, You will learn how to Install MySQL Connector Python on Windows, macOS, Linux, Unix, and Ubuntu using pip and vis...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was having all sorts of problems like this with PyMySQL (0.7.2 and 0.6.6). I switched to MySQLdb and everything is good.
I got the same error. I degraded PyMySQL from (0.7.2) to (0.6.6). It works for me. My peewee version is 2.8.0