The Python Oracle

Python 2.7, sqlite3, ValueError: could not convert BLOB to buffer

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC E Schuberts Piano Sonata D 784 in A

--

Chapters
00:00 Question
01:15 Accepted answer (Score 2)
01:47 Thank you

--

Full question
https://stackoverflow.com/questions/3983...

Accepted answer links:
[ar.tostring()]: http://docs.python.org/library/array.htm...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #sqlite

#avk47



ACCEPTED ANSWER

Score 2


Cristian Ciupitu's note about the bug is correct, but bytes(ar) will give you the __str__ representation instead of a serialized output. Therefore, use ar.tostring().

Use array.fromstring to unserialize the array again - you have to create an array object with the same type and then call .fromstring(...).