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


Groups > comp.lang.python > #51656

Re: Problem with psycopg2, bytea, and memoryview

From "Frank Millman" <frank@chagford.com>
Subject Re: Problem with psycopg2, bytea, and memoryview
Date 2013-07-31 15:41 +0200
References <ktam8i$hj3$1@ger.gmane.org><loom.20130731T114936-455@post.gmane.org><ktat7p$t70$1@ger.gmane.org> <loom.20130731T150154-520@post.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.25.1375278106.1251.python-list@python.org> (permalink)

Show all headers | View raw


"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


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web