Problem with psycopg2, bytea, and memoryview
Antoine Pitrou
solipsis at pitrou.net
Wed Jul 31 09:07:33 EDT 2013
Frank Millman <frank <at> chagford.com> writes:
>
> Thanks for that, Antoine. It is an improvement over tobytes(), but i am
> afraid it is still not ideal for my purposes.
I would suggest asking the psycopg2 project why they made this choice, and
if they would reconsider. Returning a memoryview doesn't make much sense IMHO.
For example, the standard sqlite3 module returns bytes for BLOB columns,
and str for TEXT columns:
http://docs.python.org/3.4/library/sqlite3.html#introduction
> Can anyone explain *why* the results do not compare equal? If I understood
> the problem, I might be able to find a workaround.
Well, under recent Python versions, they should compare equal:
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> memoryview(b"abc") == b"abc"
True
Regards
Antoine.
More information about the Python-list
mailing list