Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51656 > unrolled thread

Re: Problem with psycopg2, bytea, and memoryview

Started by"Frank Millman" <frank@chagford.com>
First post2013-07-31 15:41 +0200
Last post2013-07-31 15:41 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Problem with psycopg2, bytea, and memoryview "Frank Millman" <frank@chagford.com> - 2013-07-31 15:41 +0200

#51656 — Re: Problem with psycopg2, bytea, and memoryview

From"Frank Millman" <frank@chagford.com>
Date2013-07-31 15:41 +0200
SubjectRe: Problem with psycopg2, bytea, and memoryview
Message-ID<mailman.25.1375278106.1251.python-list@python.org>
"Antoine Pitrou" <solipsis@pitrou.net> wrote in message 
news:loom.20130731T150154-520@post.gmane.org...
> 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.
>

I'll try it, and see what they say.

> 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
>

I am using Python 3.3.2.

If I try your example above, it does work.

However, for some reason, after a round-trip to the server, they do not 
compare equal.

See my original post for a full example.

Frank


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web