Pyton buffer type vs psycopg2.Binary

Oswaldo Hernández <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
Hello,

I just starting to work with bytea fields. I see the binary.py example that uses psycopg2.Binary to 
covert the file data to bytea fields.

But making tests i discover that:

1. When I read the bytea field psycopg2 returns the data as <type 'buffer'> instead psycopg2.Binary.

2. psycopg2.Binary don't support __cmp__, then, if I try to compare two psycopg2.Binary objects is 
always False bacause the comparison is made with the objects id() instead the objects data.

3. In the tests i try to save de data using 'buffer(open(file, "rb").read())' instead of 
'psycopg2.Binary(open(file, "rb").read())' and, at this moment, it works fine.

The question is:

Is there any disadvantage or any other problem if i use the buffer type instead psycopg2.Binary?

Thanks.

-- 
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************
PD:
Antes de imprimir este mensaje, asegúrese de que es necesario.
El medio ambiente está en nuestra mano.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.