On Tue, Jun 18, 2019, at 9:14 AM, Guy Zehavi wrote:
> When I use sqlalchemy using mysql-connector-python to read unicode from a 
> blob I am getting:


Hi there -

While this issue may be impacted if you are using an old version of 
mysql-connector-python or of SQLAlchemy, assuming you are on the latest version 
of everything, then we have to conclude this driver has issues in this area.

Please try a driver such as mysqlclient or pymysql. mysql-connector-python is 
known to have lots of ongoing issues particularly in the area of unicode 
translation; the previous two drivers will accept BLOB values as bytes without 
issue.



> `Error closing cursor
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9a in position 3: 
> invalid start byte`
> Now, I can solve this by doing `, connect_args={'use_pure': True}` to the 
> `create_engine`. But that smells bad and I wanted to know the 'proper' way to 
> do this; notably how do I put a Blob using SqlAlchemy? I have:

> `my_blob = Column(BLOB, nullable=True)`

> Does anyone know how to assign bytes the the above column? I assume 
> `my_object.my_blob = the_bytes` however that does not work. Specifically, my 
> Blob is of type `bytes` (I get it from a protobuff being serialized). Is 
> there anything else I need to do?

> 

> --
>  SQLAlchemy - 
>  The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
>  To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
>  --- 
>  You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
>  To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
>  To post to this group, send email to sqlalchemy@googlegroups.com.
>  Visit this group at https://groups.google.com/group/sqlalchemy.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/b5982571-7098-4bdd-8670-5102dd955ee1%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/b5982571-7098-4bdd-8670-5102dd955ee1%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/11526203-eccb-40d0-9f75-423c282e4cc5%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to